commons-app / commons-app.github.io

Website for the Android Commons app
https://commons-app.github.io
Apache License 2.0
16 stars 27 forks source link

Simple web form for adding campaigns or news #35

Open maskaravivek opened 5 years ago

maskaravivek commented 5 years ago

Now that we maintain our campaigns/news in this repository, it would be useful to have a simple web interface that lets you add a campaign rather than editing the JSON file manually.

Editing it manually requires an understanding of JSON and can also lead to human errors.

To still keep things under our control, the form can simply create a pull request which the collaborators can review and merge.

Github API: https://developer.github.com/v3/pulls/#create-a-pull-request

sivaraam commented 5 years ago

Sounds interesting. Thinking out loud, could this just be done with some JavaScript? We can't do server side code as the website is hosted in GitHub pages.

If this could just be done with JavaScript then I could take a stab at this.

maskaravivek commented 5 years ago

Yes, I was hoping to have it done just with some Javascript and HTML. Even I am not 100% sure about the feasibility of the task and there might be simpler ways to do it. The intent is to make it simpler to submit news and campaigns.

sivaraam commented 5 years ago

I was thinking about this for some time. Pondering into the GitHub resources gives me an idea that we could achieve this either via:

  1. a GitHub OAuth application
  2. a GitHub app
  3. By having a separate account (which can be used via a personal access token).

I think I know the right choice for this problem. GitHub seem to have a useful flow-chart (shown below) in their help page about apps:

Useful diagram about different apps

For me the flow-chart leads to "GitHub app" as the solution for the problem in hand. I'm open to other thoughts and opinions, though :slightly_smiling_face:

The challenging thing with all the ways is that they require you save some kind of secret to be kept.

  1. GitHub OAuth app - a client secret
  2. GitHub app - a private key file
  3. Separate account - the personal access token

Unfortunately, keeping the secret in code (which makes it public) is not a good thing. So, we can't do this simply without some server side code. Heroku's free plan seems promising. May be we could use it to host the application.

Any thoughts? :ear:

sivaraam commented 5 years ago

@maskaravivek @domdomegg @nicolas-raoul @misaochan Any thoughts?

domdomegg commented 5 years ago

A temporary solution could be to make the front end editor bit and it'd just spit out a .json file to upload. I can do this soonish I think. In the future for automating the PRs Heroku (free-tier) or AWS Lambda (the free plan provides 1 million launches/month) would probably work well.

Enabling Travis (see https://github.com/commons-app/campaigns/pull/6) should tell us if it will cause any issues with syntax. That PR (the Travis config file) was merged but Travis itself wasn't enabled for the repo - can someone with write-access there enable it at https://travis-ci.com/organizations/commons-app/repositories please.

domdomegg commented 5 years ago

Also ideally we'd get the campaigns from commons automatically - is there anywhere where there is a list of campaigns?

This is the closest I seem to be able to get, but it's not at all machine readable: https://commons.wikimedia.org/w/index.php?title=Special:AllPages&from=&namespace=460

misaochan commented 5 years ago

I've accepted the request to enable Travis for the campaigns repo, thanks @domdomegg ! Would anything else be needed?

misaochan commented 5 years ago

Also ideally we'd get the campaigns from commons automatically - is there anywhere where there is a list of campaigns?

I was trying to find this out when we were implementing "display campaigns in app", but unfortunately there did not appear to be any that satisfied our requirements (e.g. start date and end date). That's why we ended up with the campaigns repo.

misaochan commented 5 years ago

Heroku's free plan seems promising.

@sivaraam This looks good to me at first glance, however it does seem to be a bit more involved than what @domdomegg appears to be planning (albeit perhaps a better long-term option).

I definitely agree that we should not store the secret publicly. ;)

domdomegg commented 5 years ago

I've accepted the request to enable Travis for the campaigns repo, thanks @domdomegg ! Would anything else be needed?

Thanks! Just did some testing, all seems to be working well now 🎉: https://github.com/commons-app/campaigns/pulls?utf8=%E2%9C%93&q=is%3Apr+created%3A2019-06-09..2019-06-09+

sivaraam commented 5 years ago

A temporary solution could be to make the front end editor bit and it'd just spit out a .json file to upload. I can do this soonish I think.

You are correct. I was thinking long term. If you're interested you could make the temporary solution which we could integrate as a sub-page of the website :slightly_smiling_face:

In the future for automating the PRs Heroku (free-tier) or AWS Lambda (the free plan provides 1 million launches/month) would probably work well.

I'll think more about the long-term solution using Heroku. Of course, you could give your inputs which I'm most welcome to :slightly_smiling_face:

Also ideally we'd get the campaigns from commons automatically - is there anywhere where there is a list of campaigns?

You're correct. Maintaining this repository is hard and we would of course better have an API like interface to get the campaigns. I'll try poking around for it too, to see if I could find anything. May we could ask some help with this in a technical advice IRC meeting

sivaraam commented 4 years ago

Just for the sake of completion an initial working version of the campaigns editor (credits: @domdomegg) can be found at https://commons-app.github.io/campaigns-editor

Instructions about how to use it to update the campaigns in the campaigns repository could be found in the README of the campaigns repository.