-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serve PDF restroom sign files in multiple languages #563
Comments
Hi @DeeDeeG ! I'm interested in working on this! |
Hi @sophiabonsu, sorry I did not notice your comment! My email inbox is overflowing!! I will take a look at this, if you are still interested, and I will try to give some direction on how to proceed. (Please do leave another comment here if you are still interested.) |
Hello @DeeDeeG !!! I’m still very interested in working on the issue ! I’m having trouble with the installing the development environment. I installed the docker and my laptop has been much slower since. It’s an older MacBook(2009), so I suppose that the problem. Any additional guidance would be greatly appreciated. |
Hi again, @sophiabonsu. First thing, I think it would be good to ensure you have a workable development environment, so that is what I will comment about first.
Either using Docker or working outside of Docker is fine, whichever you prefer. Regarding technically fixing this issue (#563): This should be the only file we need to edit to make PDF signs available in multiple languages: https://github.com/RefugeRestrooms/refugerestrooms/blob/develop/app/views/pages/signs.html.haml It is written in Haml, which is a language designed to make HTML more concise, and the syntax is more like a programming language than HTML. But it is mostly just HTML written in a different coding style. (It gets interpreted and turned into HTML before it is sent to the site visitor's browser). It allows you to embed Ruby code (with the equals sign We can dynamically choose which language of restroom sign PDF to put in the page based on the visitor's locale setting ( I would suggest looking at the page's haml code and the Restroom signs page at refugerestrooms.org (https://refugerestrooms.org/signs) to compare, and try to see where the parts of the haml page show up in the final HTML document. The haml code includes some Rails framework helpers, especially for embedding images files and hyperlinks. They looked tricky to me at first, but they made sense to me eventually. I hope you will also find it makes enough sense to work with it. Strategies for implementing this: There are two ways to go about it:
(this would be simplest) Just insert a hyperlink into the haml markup, linking to the French PDF signs under the existing links (to the English signs). Eventually it might be nice to make a preview PNG image of the French signs like we have for the English signs.
For this approach, it makes sense to me to program the page to get the user's locale (reading the Rails Internationalization API by reading the value of Lastly a note: I myself am not an expert programmer (I'm self-taught) but I think the level of programming will not be extremely difficult for this task. If you need info about Haml or Ruby, I am happy to link to documentation or give my own explanation of certain concepts, so if you need any help with the programming part, or if the structure/tech of this project/repo is unclear, I am happy to answer any questions. I enjoy teaching, and time permitting I will be glad to answer questions about anything that comes up. |
That's a pretty sweeping overview, but if you have anything more specific you want answered, I can do that. Hope it's helpful (and not overwhelming). Best Regards, - DeeDeeG |
For more help with Haml (I think this would be the trickiest part for someone not familiar with it) here are some resources:
Here's our Haml source for the restroom signs PDF page... turned into HTML with embedded Ruby code. (Click this text to expand/give this text keyboard focus and press "Enter" to expand.)<div class="text-padding">
<h1>
<%= t('.title') %>
</h1>
<p>
<%= t('.intro') %>
</p>
<div style="float:left;width:45%;text-align:center;margin:0 15px;">
<h3>
<%= t(".head-accessible") %>
</h3>
<a href="/rr-sign-with-handi.pdf">
<%= image_tag('rr-sign-with-handi.png', :style => "padding:15px;border:1px solid #444;") %>
</a>
<p>
<%= t(".download") %>
</p>
<%= image_tag('qrcode-sign-with-handi.png', :width => "200") %>
</div>
<div style="float:left;width:45%;text-align:center;margin:0 15px;">
<h3>
<%= t(".head-non-accessible") %>
</h3>
<a href="/rr-sign-no-handi.pdf">
<%= image_tag('rr-sign-no-handi.png', :style => "padding:15px;border:1px solid #444;") %>
</a>
<p>
<%= t(".download") %>
</p>
<%= image_tag('qrcode-sign-no-handi.png', :width => "200") %>
</div>
<div style="clear:both;">
<br/>
</div>
</div> Should be easier to read, to understand how the Haml turns into HTML. Ruby code explanations:
|
Hmm, I have to correct my earlier comments about setting up the development environment outside of Docker. I mis-remembered how far I was able to get testing outside of Docker. My apologies for not testing the steps in my comment. The webapp does not seem to work at all outside of Docker if PostgreSQL is not running locally. Also, NodeJS must be installed, or Rails will not run. Here is a proper explanation posted by another contributor to Refuge Restrooms some time ago: #413 (comment) (Since this was posted, we have added NodeJS to our web app, so you must also install NodeJS. It can be downloaded and installed from here: https://nodejs.org/en/download/ We use NodeJS (LTS) v12, but v13 should also work -- the version you download should not matter.) |
I got an email notification of an issue you had run into. I can look into it, but I'm not familiar with that particular error message. Hopefully it has gone away by now/been resolved? WebPacker is a sort of low-level, automated thing. I don't think this project has changed the configuration/setup of WebPacker in a bit, so it should be working. In order to make sure the docker image built correctly, I would suggest to try rebuilding the docker image with something like (If it finishes rebuilding very quickly, then it is using a cached version of a previous Essential docker cleanup commands:
More-advanced stuff:
|
Scope / difficulty
Not too difficult.
Should just have to either:
Also need to make .png preview images to go with the new PDF signs.
Also also, we possibly want to generate new QR codes to correspond to the new signs' URLs.
Impact
Allows the PDF restroom signs to be downloaded and used for a French-speaking audience, in addition to the existing English-language signs. Establishes a workflow for adding PDFs in additional languages down the line.
Proposal
Option 1: Add some Ruby code to logically "branch" which PDF is served based on the site language being served overall.
Pseudocode:
Option 2: Add all PDF signs we have to the PDF signs page, so they may all be viewed by any viewer of the site, regardless of language.
This is just adding additional image
<img>
tags inside of link<a>
tags (with Rails image/link helpers...) leading to the FR PDF files. No branching logic required in this case.Addendum for either plan: We should make some .png preview images for the new PDF signs. We can generate QR codes for the new signs' URLS as well.
How to actually do this:
To generate .PNG previews, I think just opening the PDF in a PDF viewer of some kind and forcing the dimensions to match the existing preview .pngs (300px x 228px)4 would do.
To generate QR codes from a given URL, there are multiple tools online. 1 2 3 etc. They can be validated using the open-source ZXing decoder: https://zxing.org/w/decode.jspx
(e.g. one of our current QR codes: https://zxing.org/w/decode?u=https%3A%2F%2Frefugerestrooms.org%2Fassets%2Fqrcode-sign-with-handi-130dbfcb039cd8374e68fc3834cae54624b2a291a3a096021aef0850beec58f1.png
has the "URI" data type, and actually leads to "http://refugerestrooms.com/rr-sign-with-handi.pdf". Maybe we should update the old ones to use HTTPS and go to our
.org
URL, rather than the.com
one?The text was updated successfully, but these errors were encountered: