Skip to content
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

Contact Page looks awful #232

Open
reesericci opened this issue Aug 6, 2022 · 27 comments
Open

Contact Page looks awful #232

reesericci opened this issue Aug 6, 2022 · 27 comments
Assignees
Labels
Milestone

Comments

@reesericci
Copy link
Collaborator

The contact form page has no styling and is an iFrame of a 3rd-party service. It should be set up where the form is hosted on the JB site with all the JB styling and then submits the results with the action parameter to a 3rd-party API which processes the form and sends an email or whatever.

@reesericci
Copy link
Collaborator Author

Why does the upload an image field exist if nobody is supposed to use it?

image

@reesericci
Copy link
Collaborator Author

@gerbrent
Copy link
Collaborator

gerbrent commented Aug 6, 2022

I love the frankness of this issue title ; )

@gerbrent gerbrent added third-party site design design and visual labels Aug 6, 2022
@gerbrent gerbrent added this to the JB.com 2.0 milestone Aug 6, 2022
@reesericci
Copy link
Collaborator Author

Imo this is important for the 1.0 milestone to properly create a consistent contact form.

@reesericci
Copy link
Collaborator Author

I'd be willing to work on it if I know what API I'm tying into.

@gerbrent gerbrent modified the milestones: JB.com 2.0, JB.com 1.0 Aug 7, 2022
@gerbrent gerbrent added the JB - action needed action needed from a JB Team member label Aug 7, 2022
@ErraticKnight
Copy link

I'm guessing that would explain the weird behavior I saw yesterday there. If you drag the comment box's resizing corner you can pull far enough down to push the UI that lives below underneath the footer; if you pull enough you can get the hot zone for the resize corner pulled underneath the footer as well which makes the change unfixable.

@elreydetoda
Copy link
Collaborator

Related to #139, the original plan that @kbondarev and I chatted about over there was to just have an API on the backend the form is submitted to. (so everything is self hosted)

We stopped pursuing that, because we had (at the time) though that the old contact form would be enough for the 1.0 release. Then we could do the re-write possibly for 2.0.

We're still only at 50% and there is still plenty to do, is there a critical reason why the 1.0 can't just re-use the old one? Since this is mainly an MVP (or Minimum Viable Product) for the 1.0 release, as long as people can still properly write in and submit feedback then IMO I think this could be put back to 2.0. ( trust me I know I'd love to add a bunch of things as well 😅)

The other thing to take into consideration is that if we change this, we might change the internal JB workflow. Which is probably a good thing to make it easier for them, than just consuming emails from a 3rd party. I think if we take our time on this and do it right, then we could make it really nice and easy for the JB team to get feedback. Making that all work for them by the launch deadline though, doesn't seem easily feasible (without it being someone dedicated to coordinate everything I mentioned above).

(Just my 2 cents)

@elreydetoda
Copy link
Collaborator

Why does the upload an image field exist if nobody is supposed to use it?

image

I'd imagine it's probably a storage or space requirement, because depending on the provider they might only get images depending on their size. (Completely hypothesizing)

@elreydetoda
Copy link
Collaborator

elreydetoda commented Aug 8, 2022

I'm guessing that would explain the weird behavior I saw yesterday there. If you drag the comment box's resizing corner you can pull far enough down to push the UI that lives below underneath the footer; if you pull enough you can get the hot zone for the resize corner pulled underneath the footer as well which makes the change unfixable.

I wonder (as a temporary fix) if we make the iframe scrollable (I think we can do that) then it would allow you to still access it?

Thanks for the heads up and good testing @ErraticKnight! 😁

@reesericci
Copy link
Collaborator Author

But if we make the iFrame scrollable, then everyone has to look at an ugly scrollbar - which they wouldn't need to use unless on rare occasions.

@elreydetoda
Copy link
Collaborator

Ya, that's a fair point. Also, looks like the current JB website has the same issue. So, honestly we probably should just leave it.

I hate saying that, but you can actually scroll inside the box if you don't drag it at all as well. So, I think just leaving it as is would be the easiest solution currently.

@gerbrent
Copy link
Collaborator

gerbrent commented Aug 8, 2022

Related to #139, the original plan that @kbondarev and I chatted about over there was to just have an API on the backend the form is submitted to. (so everything is self hosted)

We stopped pursuing that, because we had (at the time) though that the old contact form would be enough for the 1.0 release. Then we could do the re-write possibly for 2.0.

We're still only at 50% and there is still plenty to do, is there a critical reason why the 1.0 can't just re-use the old one? Since this is mainly an MVP (or Minimum Viable Product) for the 1.0 release, as long as people can still properly write in and submit feedback then IMO I think this could be put back to 2.0. ( trust me I know I'd love to add a bunch of things as well sweat_smile)

The other thing to take into consideration is that if we change this, we might change the internal JB workflow. Which is probably a good thing to make it easier for them, than just consuming emails from a 3rd party. I think if we take our time on this and do it right, then we could make it really nice and easy for the JB team to get feedback. Making that all work for them by the launch deadline though, doesn't seem easily feasible (without it being someone dedicated to coordinate everything I mentioned above).

(Just my 2 cents)

@elreydetoda - all of this is perfect spot on for how we're approaching the project currently - imprelement essentials first, then the nice-to-haves after our Milestone 1 publish date. Your considerations of JB's internal workflows is also super appreciated, since we certainly want to reduce the number of changes to our everyday workflow, especially considering we will be going into the JB Road Trip to JPL crunch time just about when this all gets up and running. So, all that to say: We really, really appreciate your perspective here. ❤️

@gerbrent
Copy link
Collaborator

gerbrent commented Aug 8, 2022

I'd be willing to work on it if I know what API I'm tying into.

@reesericci - aware this somehow didn't get mentioned here. Whoopsie.

API to target is Wufoo: https://wufoo.github.io/docs/#form-fields

reference: https://jblive.wufoo.com/embed/w7x2r7/

@reesericci
Copy link
Collaborator Author

I'll get to work writing up a quick form that ties into wufoo!

@gerbrent gerbrent added in progress currently being worked on and removed JB - action needed action needed from a JB Team member labels Aug 9, 2022
@reesericci
Copy link
Collaborator Author

I won't be able to work on this for a little while - I'll relinquish my assigned status for now.

@reesericci reesericci removed the in progress currently being worked on label Aug 12, 2022
@reesericci reesericci removed their assignment Aug 12, 2022
@elreydetoda
Copy link
Collaborator

Thanks for keeping us updated @reesericci and letting us know when you don't have time to do something. 🚀

It's hard to keep track of that and keep boundaries for things you enjoy, so thank you for letting us know 😁🚀

@elreydetoda
Copy link
Collaborator

I think this could be moved to 2.0, unless someone has time to work on it for 1.0. We already have a form, yes it doesn't look the best but it'll be replaced eventually anyways (for something a bit nicer).

@gerbrent gerbrent removed this from the JB.com 1.0 milestone Aug 17, 2022
@gerbrent gerbrent added this to the JB.com 2.0 milestone Aug 17, 2022
@CGBassPlayer
Copy link
Collaborator

I think I will take a crack at trying this since I have #485 (which is the second time the iframe failed us). I'll steal all the info in this issue and see what I can come up with. I am still lacking in free time so I won't promise anything, but I really want to revive this

@reclaimingmytime
Copy link
Contributor

I looked into this a few months ago. I remember that you need to be careful not to expose the Wufoo API Key in the frontend. So, just making a web request via JavaScript would not be an option with the API.

From the docs (https://help.wufoo.com/articles/en_US/kb/Wufoo-REST-API-V3):

You'll need your API key to use the Wufoo API. Your API key is unique to your account and grants access to your data, so make sure to keep it protected the same way you'd protect your password.

Because we're using Hugo, we can't just put the logic in the backend like in other web frameworks. The alternative could be some server-side code which would require more maintenance, or using an entirely new API.

@CGBassPlayer
Copy link
Collaborator

Another option would be to create an environment file that contains the API key and is only on the VPS and passed through to the Docker compose? I haven't looked too into this too much but I would imagine there must be some way to get it in vanilla JS. I'll be looking into this idea shortly

@reclaimingmytime
Copy link
Contributor

I believe the environment file would only prevent people to view the API key in the repo.

If the API request to Wufoo is done on the client-side, the API key must reach the user's browser somehow, allowing them to see it. Even when the API key is encrypted and decrypted to make it harder to view in the source code, the user can just use the network tab of their browser and see the API key in the request made to Wufoo.com.

Just my thoughts on this. Maybe there's something I'm missing.

@CGBassPlayer
Copy link
Collaborator

CGBassPlayer commented Jan 23, 2023

So crazy thought to throw out here...

What if we did a super small FastAPI app acting as a sort of proxy in its own docker container that can manage things like this? Set up an endpoint that basically just forwards the JSON body and that adds the API key. Then the client side would see the request to the backend and hides the secrets.

An approach like this would add minimal resources to the production deployment as a basic python-uvicorn style container could be pretty small.

How far off base does something like this sound? I know it is not ideal with a static website, but I think it would be wayyy better than the iframe of the form we currently have. Probably would be its own repo as well

@reclaimingmytime
Copy link
Contributor

reclaimingmytime commented Jan 23, 2023

That could work. We wouldn't be exposing the API key to the client.

On a related note, I just found out that Wufoo might directly support what we're trying to do here.

I created a Wufoo account and a dummy contact form when I was looking into this a few months ago. On the "API Information", I see the following:

POSTing From Your Site
In some cases, you may want to embed markup straight into your site (not in an iframe), but at the same time you do not want to learn our API. We do allow you to do this, but there are a few things to consider. We outline the details in our POST documentation. In addition to the docs, you will need the POST key below to get started.

Your POST Key: [key]

"POST documentation" links to "nameofcontactform.wufoo.com/docs/api/", which redirects to https://help.wufoo.com/articles/en_US/kb/Wufoo-REST-API-V3. I can't find any info about a "POST key" on the documentation, so maybe this feature is no longer supported.

The only public mention of "POST key" on Wufoo.com is in this blog post: https://www.wufoo.com/blog/sweet-code-manager-upgrades/

Now, when you use our HTML/CSS code export, your forms include all the appropriate markup changes to make it so it can just submit straight to Wufoo’s servers without having to find the action URL or grab your API POST key. Just download the zip file with our markup and it’ll be able to submit straight to Wufoo’s servers right from the get go.

So maybe we can just export the HTML from Wufoo and work with that? Maybe copying the HTML from the current iframe at https://jblive.wufoo.com/embed/w7x2r7/ (with form, action, etc.) would bring the same result? If we have access to the HTML, we would have full control over the style.


Edit: Turns out that we can't just copy the HTML from the iframe, because a hidden input field with the id "idstamp" always gets a new random value. When I exported a form as HTML, the "POST key" is in there, so that's where the key is used. Seems like a weird way to get around some CSRF protection to me.

The question is still if we want to go with the Wufoo way of using a "POST key" and an exported form, or your suggestion of a separate backend.

@reesericci
Copy link
Collaborator Author

reesericci commented Jan 23, 2023

I think having a FastAPI endpoint is a bit overkill - a serverless edge function from the likes of Cloudflare or Deno would be much easier to get up and running and do the same thing.

@CGBassPlayer
Copy link
Collaborator

I was only thinking FastAPI to go along with our python testing and have something we could have grow with us as the website adds more and more. Definitely not against using Cloudflare though.

@CGBassPlayer
Copy link
Collaborator

CGBassPlayer commented Jan 7, 2024

I have a couple ideas on how to clean up this contact form. I have already started prepping the new contact form on the front end, but I need to start looking at the backend of this form and getting it to Wufoo.

start of new contact form

What would the feasibility of of hosting an additional container to call the Wufoo API. I am thinking the something along the lines of:

  1. User enters feedback on form built on the website
  2. When the user submits the data, it calls out to this API container with the data from the form
  3. The API takes the data and calls Wufoo with the credentials and submits the form.

My other idea was getting that idstamp from a wufoo form. @reclaimingmytime had mentioned that this randomly generated string was hidden in the form. I am thinking we could add some JS that when the user loads the contact page, it would call the wufoo form, extract that idstamp field. Something like this:

  1. User loads contact page
  2. JB site calls out to the wufoo form and extracts the idstamp from the html
  3. When the user submits the data, we call the same submit function the wufoo form does with the retrieved idstamp

To me the better idea seems like the separate container for the API. My hesitation to this though is then we are introducing a backend to static website. But I am curious to know what others think about these ideas.

@reclaimingmytime
Copy link
Contributor

reclaimingmytime commented Jan 8, 2024

The frontend looks great so far. I'm sure the native form would also improve loading times compared to the current external iframe.

I prefer a solution without another backend. Your first option secures the key from the client, but the key still needs to be stored somewhere. I'm sure it can be secured easily with a proper backend so the key is not available to the client, but it is still something we need to worry about. It would be better if we wouldn't have to worry about storing sensitive API keys at all. Also, this would be another external service that someone needs to maintain.

I like the second idea of fetching the idstamp field via JavaScript. I tried that with a different Wufoo form, and that seems to work. I thought cross-origin would be an issue because of the different domains, but wufoo.com has the Access-Control-Allow-Origin header set to *.

@CGBassPlayer CGBassPlayer self-assigned this Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants