Skip to content

Simple web form for adding campaigns or news #35

@maskaravivek

Description

@maskaravivek
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

Activity

sivaraam

sivaraam commented on Mar 31, 2019

@sivaraam
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

maskaravivek commented on Mar 31, 2019

@maskaravivek
MemberAuthor

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

sivaraam commented on May 18, 2019

@sivaraam
Member

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

sivaraam commented on Jun 9, 2019

@sivaraam
Member
domdomegg

domdomegg commented on Jun 9, 2019

@domdomegg
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

domdomegg commented on Jun 9, 2019

@domdomegg
Member

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

misaochan commented on Jun 9, 2019

@misaochan
Member

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

misaochan

misaochan commented on Jun 9, 2019

@misaochan
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

misaochan commented on Jun 9, 2019

@misaochan
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

domdomegg commented on Jun 9, 2019

@domdomegg
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

sivaraam commented on Jun 9, 2019

@sivaraam
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.

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

sivaraam commented on Nov 14, 2019

@sivaraam
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @nicolas-raoul@maskaravivek@misaochan@domdomegg@sivaraam

        Issue actions

          Simple web form for adding campaigns or news · Issue #35 · commons-app/commons-app.github.io