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

Simple web form for adding campaigns or news #35

Open
maskaravivek opened this issue Mar 30, 2019 · 12 comments
Open

Simple web form for adding campaigns or news #35

maskaravivek opened this issue Mar 30, 2019 · 12 comments

Comments

@maskaravivek
Copy link
Member

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
Copy link
Member

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
Copy link
Member Author

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
Copy link
Member

sivaraam commented May 18, 2019

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 🙂

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? 👂

@sivaraam
Copy link
Member

sivaraam commented Jun 9, 2019

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

@domdomegg
Copy link
Member

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 commons-app/campaigns#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
Copy link
Member

domdomegg commented Jun 9, 2019

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
Copy link
Member

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

@misaochan
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

sivaraam commented Jun 9, 2019

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 🙂

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 🙂

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants