CodeForFoco / codeforfoco.github.io

Code for Foco's website.
http://codeforfoco.org
MIT License
9 stars 24 forks source link

Idea submission form -- backend #36

Closed JordanMajd closed 7 years ago

JordanMajd commented 7 years ago

EDIT: breaking this out into separate front/back end issues. -Jason

Add an idea submission form to the website which emails out the team or sends a message to slack.

"Hey you've got an idea to make Fort Collins better? Let us know your thoughts."

abettermap commented 7 years ago

Instead of email or Slack, what if the output could be a GitHub issue or a comment on https://github.com/CodeForFoco/org/issues/17? I guess it would require an account to post as, but just a thought.

JordanMajd commented 7 years ago

@abettermap I really like that idea.

Email is simple to implement, we could just use FormSpree.

Slack can be simple if we use a tool like this. Alternatively, building our own integration isn't too difficult, it just would require a backend API to securely hold our Slack API keys.

Your Github suggestion is my favorite. The first solution that comes to mind, create an account (e.g. CFFC-Bot) and use it to create issues / comments via the API, create a backend API to securely hold our Slack API keys.

abettermap commented 7 years ago

Yayuh, I like it. Let's set this up Thursday at the meeting if we have time.

afibarra commented 7 years ago

Hello,

I did a little research on this, and, according to me, it is not possible to use the GitHub API because for that, we need to use a library like Octokit (https://github.com/octokit/octokit.rb) which is the library suggested by GitHub to use with Ruby (https://developer.github.com/libraries/).

Using this library means that we should be able to execute ruby code on the server, and that is not possible. At least not in GitHub.

FormBot looks nice and easy to do. I'm going to work on it.

Thank you.

abettermap commented 7 years ago

Ah, bummer. Would this be an option? https://coderwall.com/p/8lq1ba/how-to-create-a-contact-form-for-a-github-pages-served-jekyll-website

Also, do you have a link to FormBot? I only found a Chrome extension which looks like it automates form populating rather than building: https://chrome.google.com/webstore/detail/formbot/ilnjaomgpkbmapjachcppgabkidbmnjc?hl=en

afibarra commented 7 years ago

Hello,

This is the link: https://stacktodo.com/tools/form

abettermap commented 7 years ago

Yeah definitely not what I was looking at haha. That looks promising so I'd say it's certainly an option, assuming the Heroku thing from my link isn't worth it or isn't feasible (it does sound kinda overkill to me).

A similar option would be Google Forms, which would let us store the ideas in a spreadsheet. I guess it depends what we plan on doing with the ideas later. Slack = better for discussion, Google Sheets = easier storage and analysis.

Another bonus to the Google approach is that the output could be public, which seems like something we/they would want. We could provide a link to the spreadsheet below the form saying "View current ideas" or something, to maybe give users additional ideas or to see if theirs has already been suggested.

afibarra commented 7 years ago

Using Heroku sound little overkill indeed but I think it is the only way to execute code.

Maybe, based on that article, then is possible to call GitHub API from Heroku and be able to create issues / comments from the website...

JordanMajd commented 7 years ago

We have a free tier Heroku instance running Node app for our Slack invites.

We could add another API endpoint to handle idea submissions.

Might be overkill but could be fun.

JordanMajd commented 7 years ago

If we do go this route we could set up a CORs policy for the heroku domain and the node-github library.

abettermap commented 7 years ago

@afibarra Sounds like we are going to try the Heroku thing. Do you want me to assign this issue to you?

@JordanMajd Whoever is doing this would need Heroku credentials, yeah?

afibarra commented 7 years ago

@abettermap @JordanMajd Yes, assign it to me

Actually, I'm think I finished it. But it is a java application, not a Node.js one. I don't have much time to learn Node.js :). Even though, it took me some time to figure it out how to deploy a Java EE app in Heroku, because Heroku only runs Java SE applications.

I tested the app against one of my public GitHub repositories.

I tested using curl as follows: curl --data "issueTitle=New Issue1&userComment=User Comment1" http://salty-journey-24179.herokuapp.com/createIssue

And this is what you can see in the Heroku server log file:

2017-02-12T06:12:04.151234+00:00 app[web.1]: 2017-02-12 06:12:04,151 INFO [com.jcabi.http.request.BaseRequest] (default task-1) #fetch(POST api.github.com /repos/afibarra/afibarra.github.io/issues): [201 Created] in 489ms 2017-02-12T06:12:04.238222+00:00 app[web.1]: 2017-02-12 06:12:04,237 INFO [com.jcabi.http.request.BaseRequest] (default task-1) #fetch(GET api.github.com /repos/afibarra/afibarra.github.io/issues/7): [200 OK] in 70ms

According to me it is possible to transfer the ownership of a GitHub repo and a Heroku App as well to other person, in this case, you of course.

Thank you, Armando

abettermap commented 7 years ago

Nice work! We will want to include a label of some sort as well, probably project idea, and maybe use some kind of comment template to present the info neatly (including the idea's category or other meta stuff). We might also need a way to contact the submitter without exposing their email publicly, assuming they want to be contacted.

I will defer to @JordanMajd for the Heroku stuff and repo transfer as I know nothing about it, but it sounds like the Java approach is a nice solution.

I don't think I can assign it to you if you're not a repo member but it's all yours.

JordanMajd commented 7 years ago

@afibarra good work!

I'll look into what it takes to transfer the repository and the heroku instance.

JordanMajd commented 7 years ago

The issue submission backened is done thanks to @afibarra and can be found here.

The next steps are:

  1. Create gh account to use as submission bot
  2. Deploy backend to heroku
  3. Create front end form on website.
JordanMajd commented 7 years ago

Closed.

The backend can be found here. It still needs to be deployed but that is an issue tracked in it's own repo.