Commit c8da5837 authored by Vincent's avatar Vincent

Merge branch 'master' of gitlab.com:Flockademic/whereisscihub

parents dd998e54 eb513214
Pipeline #25531966 passed with stage
in 3 minutes and 5 seconds
image: node:8
stages:
- review
- deploy
variables:
REPO_NAME: whereisscihubnow
start_review:
stage: review
script:
- npm install -g --unsafe-perm now
- URL=$(now --public -t ${NOW_TOKEN} -n ${REPO_NAME}-${CI_COMMIT_REF_SLUG})
- NOW_URL=$(echo ${URL} | sed s/'http:\/\/'/''/g | sed s/'https:\/\/'//g)
- now -t ${NOW_TOKEN} alias set ${NOW_URL} ${REPO_NAME}-${CI_COMMIT_REF_SLUG}.now.sh
environment:
name: review/$CI_BUILD_REF_NAME
url: https://$REPO_NAME-$CI_COMMIT_REF_SLUG.now.sh
on_stop: stop_review
only:
- branches
except:
- master
stop_review:
stage: review
script:
- npm install -g --unsafe-perm now
- now rm -t ${NOW_TOKEN} -y ${REPO_NAME}-${CI_COMMIT_REF_SLUG}
when: manual
environment:
name: review/$CI_BUILD_REF_NAME
action: stop
only:
- branches
except:
- master
start_production:
stage: deploy
script:
- npm install -g --unsafe-perm now
- URL=$(now --public -t ${NOW_TOKEN} -n ${REPO_NAME}-${CI_COMMIT_REF_SLUG})
- NOW_URL=$(echo ${URL} | sed s/'http:\/\/'/''/g | sed s/'https:\/\/'//g)
- now -t ${NOW_TOKEN} alias set ${NOW_URL} whereisscihub.now.sh
environment:
name: production
url: https://whereisscihub.now.sh
only:
- master
# WhereIsSciHub
A barebones Node.js app using [Express 4](http://expressjs.com/).
Fetches the URLs currently [listed on WikiData as working for Sci-Hub](https://www.wikidata.org/wiki/Q21980377),
and hosts a webpage listing those URLs (and a service to automatically redirect the visitor to those URLs at `/go`),
and that is always up-to-date with whatever Sci-Hub URLs are currently valid.
Try it out at https://whereisscihub.now.sh/.
## Running Locally
Make sure you have [Node.js](http://nodejs.org/) and the [Heroku CLI](https://cli.heroku.com/) installed.
Make sure you have [Node](http://nodejs.org/) installed.
```sh
$ git clone git@gitlab.com:Flockademic/whereisscihub.git # or clone your own fork
......@@ -15,23 +18,30 @@ $ npm start
Your app should now be running on [localhost:5000](http://localhost:5000/).
## Deploying to Heroku
## Deploying to Now.sh
You can deploy it to [Now.sh](https://zeit.co/now) using the following command.
Note that you need your own account there (you will be asked to create one when
running the command), and that it will be deployed to a separate subdomain.
```
$ heroku create
$ git push heroku master
$ heroku open
$ npx now
```
or
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
(`npx` [is provided by the Node package manager](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b).)
## Navigating the source code
## Documentation
The app is written in Javascript and is really quite simple. It consists of a
single file, [index.html](/index.html). The meat of the application is the
function `getUrls` at the bottom of the file, which fetches the current Sci-Hub
URLs from WikiData (using [SPARQL](https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial)).
For more information about using Node.js on Heroku, see these Dev Center articles:
It also starts a small web server using [Express](https://expressjs.com/), to
serve the following endpoints:
- [Getting Started with Node.js on Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs)
- [Heroku Node.js Support](https://devcenter.heroku.com/articles/nodejs-support)
- [Node.js on Heroku](https://devcenter.heroku.com/categories/nodejs)
- [Best Practices for Node.js Development](https://devcenter.heroku.com/articles/node-best-practices)
- [Using WebSockets on Heroku with Node.js](https://devcenter.heroku.com/articles/node-websockets)
- `/favicon.ico` - the [Favicon](https://en.wikipedia.org/wiki/Favicon)
- `/api` - providing the list of URLs as [JSON](https://en.wikipedia.org/wiki/JSON)
- `/go` - directly redirect the user to the URL currently listed on WikiData as preferred
- `/go/*` - directly redirect the user to the preferred URL, passing on anything beind `/go/` to that URL. This allows users to e.g. directly append a DOI or a link to an article to find it on Sci-Hub.
- `/` - a simple HTML page listing the URLs for human consumption, and providing links to e.g. this source code :)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment