obsidienne

obsidienne

Split app by device app

Hi,

My hobby website is used by wide device and smartphone.
The design for each device is very different and using responsive technic for those differences is complex.

I have a plug using the user agent adding to the conn a Boolean smartphone(true/false). And I can pattern match on the controller function to have a specific layout.

But it’s heavy. My controllers are fat, css and js are not adapted to the device.

Is there a better way ?

Most Liked

peerreynders

peerreynders

“Responsive design” is largely about CSS - designing the site layout “mobile first” and using media queries to re-style for wider displays.

Responsive Design with CSS (code)

peerreynders

peerreynders

But you yourself have stated that

but responsive is not always the right answer, nor mobile first design

and when it isn’t, the usual (easier) solution is usually to go with different URLs typically split by domains www.wombatcoffee.com vs m.wombatcoffee.com.

Github seems to use the User-Agent request header to route the request, though it allows that to be overridden by posting a token to /site/mobile_preference which I guess creates a cookie that overrides the request header.

So as you can see using the same URL but not relying on “mobile first” responsive design can get a bit involved.

<form class="js-mobile-preference-form" action="/site/mobile_preference" accept-charset="UTF-8" method="post">
  <input name="utf8" type="hidden" value="✓">
  <input type="hidden" name="authenticity_token" value="blahblah==">
  <input type="hidden" name="mobile" value="false">
  <input type="hidden" name="anchor" class="js-mobile-preference-anchor-field">

  <button type="submit" class="switch-to-desktop" data-ga-click="Mobile, switch to desktop, switch button">
    Desktop version
  </button>
</form>

So we’re basically back to

A simpler hybrid solution could use the user agent on a (mobile first, responsive design) landing page to populate the links (/... vs /m/...) but everywhere else use separate URLs for the desktop and mobile versions.

peerreynders

peerreynders

Why similar? What is preventing you from using a Scoped Route for “mobile”.

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
Kagamiiiii
Student &amp; New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement