H
H
HaruAtari2013-09-07 12:55:59
git
HaruAtari, 2013-09-07 12:55:59

How to store the text of articles for a site on github?

Good day.
Now I'm working on a website, the main focus of which is on learning articles. And now the question arose “how to store the text of articles?”
It is necessary that any user can edit the pack test, and after checking by the moderator, the edits are applied. There are two important points:
1. The article should always be available. Those option when the article becomes unavailable for a while, until the changes are checked by the moderator, does not work. It is necessary that while the new version is awaiting verification, the old one was available on the site. And after confirmation by the moderator, it changed to a new one.
2. The site is aimed at programmers, and not beginners. Therefore, we can assume that most of the users will have an account on the github.

First, I wanted to check the current version of the article and the new one in the database. And when checking, replace the old one with a new one. But there are many problems associated with this method. The main one is that it is difficult to compare the old version of the text with the new one when checking. Change is not easy to find.

Recently, I have noticed many sites that store the texts of articles on github. Usually these are localized copies of foreign sites. For example, angular.ru And there is a “fix translation” button on the page, when you click on it, it throws us to the repository on the github.

This is how I want to organize the articles on my site. The user wanted to correct the article, made a pullrequest to the repository, the moderator checked it and uploaded it, the article was updated on the site.

In theory, everything sounds great, but I don't know how to organize it. How to pull the text of articles from github? At first I thought it was a simple inclusion, but it will work slowly. Ideally, when a pullrequest is accepted, a script would be launched on my server that would pull the new text of the article into the database. How to notify the server about changes?

Maybe someone faced a similar problem. Please tell me the best way to implement this functionality? Didn't find anything useful on google. I would be very grateful for any ideas and links.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
T
TyVik, 2013-09-07
@HaruAtari

In git, there is such a thing as a hook - an action that is performed on some kind of event. Here, on the pull request approval event, you can hang up a script call on the server via a GET request, and this script will eventually update the repository and update the page. Somehow it is implemented, in my opinion, on djbook.ru (I try to help with the translation there).

P
Puma Thailand, 2013-09-07
@opium

Everything has been implemented on the wiki for a long time, why do you need to put it in the git?

P
pomeo, 2013-09-07
@pomeo

Ideally, when a pullrequest is accepted, a script would be launched on my server that would pull the new text of the article into the database. How to notify the server about changes?

github has webhooks

@
@xave, 2013-09-07
_

First, I wanted to check the current version of the article and the new one in the database. And when checking, replace the old one with a new one. But there are many problems associated with this method. The main one is that it is difficult to compare the old version of the text with the new one when checking. Change is not easy to find.

There is also a diff utility.

A
Alexey Akulovich, 2013-09-07
@AterCattus

How about maintaining two master branches (the version on the site) and dev/new/etc for new versions of articles? Popular and well-established method.

P
Puma Thailand, 2013-09-07
@opium

Everything has been implemented on the wiki for a long time, why do you need to put it in the git?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question