Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonythomas01/gdrive-to-commons
Tool to upload pictures from Google Drive to Wikimedia Commons ⚠️ Moved to Wikimedia Gerrit, so this repo is read only.
https://github.com/tonythomas01/gdrive-to-commons
django django-rest-framework google-cloud google-drive javascript oauth pyenv pyenv-virtualenv toolforge wikimedia wikimedia-commons wikimedia-developers wikimedia-tools
Last synced: 3 months ago
JSON representation
Tool to upload pictures from Google Drive to Wikimedia Commons ⚠️ Moved to Wikimedia Gerrit, so this repo is read only.
- Host: GitHub
- URL: https://github.com/tonythomas01/gdrive-to-commons
- Owner: tonythomas01
- License: apache-2.0
- Created: 2019-05-17T15:43:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-20T16:59:09.000Z (over 1 year ago)
- Last Synced: 2024-10-11T11:23:19.870Z (4 months ago)
- Topics: django, django-rest-framework, google-cloud, google-drive, javascript, oauth, pyenv, pyenv-virtualenv, toolforge, wikimedia, wikimedia-commons, wikimedia-developers, wikimedia-tools
- Language: JavaScript
- Homepage: https://gdrive-to-commons.toolforge.org/
- Size: 8.6 MB
- Stars: 9
- Watchers: 4
- Forks: 10
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Google drive to Wikimedia Commons (Read only)
Please see: https://github.com/wikimedia/labs-tools-gdrive-to-commons
[![Build Status](https://travis-ci.com/tonythomas01/gdrive-to-commons.svg?branch=master)](https://travis-ci.com/tonythomas01/gdrive-to-commons)
This tool is developed to Upload images directly from Google drive to Wikimedia Commons and is currently deployed at [Toollabs](https://gdrive-to-commons.toolforge.org/).
## ⚠️ Contributing ⚠️
Development and codebase moved to [Wikimedia Gerrit](https://gerrit.wikimedia.org/r/admin/repos/labs/tools/gdrive-to-commons). This repo is read only now. Read how to contribute on the [Gerrit Tutorial](https://www.mediawiki.org/wiki/Gerrit/Tutorial). Thank you!
## Dependencies
We use `python 3.5.3` on production. Make sure you have this installed on
your machine, or use `pyenv` as described later in this documentation under steps for local development.## Pre-requisites for local development
The tool authenticates to the Wikimedia cluster using Wikimedia OAuth and to Google using Google OAuth. Hence, we need a couple of secret keys in your `local_settings.py` to start development.
1. `SOCIAL_AUTH_MEDIAWIKI_KEY` & `SOCIAL_AUTH_MEDIAWIKI_SECRET`: You can request for an OAuth client using [Wikimedia:OAuth](https://www.mediawiki.org/wiki/OAuth/For_Developers). Once created, you will get both keys. Remember that you set the right Mediawiki OAuth callback URL.
2. `GOOGLE_APP_ID`: We need an application running on Google cloud to authorize and access Google drive. You can create your application at [Google cloud console](https://console.cloud.google.com/). `GOOGLE_APP_ID` is your project id.
3. `GOOGLE_CLIENT_ID`: You can create a new OAuth 2.0 Client at [Google cloud credentials](https://console.cloud.google.com/apis/credentials).
4. `GOOGLE_API_DEV_KEY`: You need to enable the **Google Picker API** on Google cloud console. Once enabled, a dev key is generated, and you can find it on your [Google cloud credentials](https://console.cloud.google.com/apis/credentials).For Wikimedia developers, you can find more information on development keys [here](https://phabricator.wikimedia.org/T235969)
And also, the Google Drive to Wikimedia Commons Developer credentials are provided at the following link:
https://phabricator.wikimedia.org/P10014 .
Developers need not create new secret keys and can use the credentials given in the above link as instructed later in this documentation under steps for local development.
## Steps for local development1. Create a local fork of https://github.com/tonythomas01/gdrive_to_commons using your GitHub account by running the following command in terminal:
```
$ git clone https://github.com/username/gdrive-to-commons.git
```
2. If homebrew is not installed before, install homebrew package manager by following the instructions given in the below link:
https://docs.brew.sh/Homebrew-on-Linux
3. Install pyenv and virtual manager by running the following commands in terminal:
```
$ brew install pyenv
$ brew install pyenv-virtualenv
$ export PATH="$HOME/.pyenv/bin:$PATH"
$ eval "$(pyenv init -)"
$ eval "$(pyenv virtualenv-init -)"
$ pyenv install 3.5.3
$ eval "$(pyenv init -)"
```
4. navigate into the repository by running the following command in terminal:
```
$ cd gdrive_to_commons
```
Now you are in the `gdrive_to_commons` directory and all the following commands are run in this directory.
5. Create pyenv-virtualenv by running the following command in terminal:
```
gdrive_to_commons/$ pyenv virtualenv 3.5.3 gdrive-env-3.5.3
```
This will create a pyenv-virtualenv for you and probably place it on your `~/home//.pyenv/versions/`.
6. Activate the virtual environment manually by running the following command:
```
gdrive_to_commons/$ source ~/.pyenv/versions/gdrive-env-3.5.3/bin/activate
```
or even better:
```
gdrive_to_commons/$ pyenv activate gdrive-env-3.5.3
```
or,
there are better ways to do this if you follow https://github.com/pyenv/pyenv-virtualenv.
Now you are in the right environment if your terminal shows:
```
(gdrive-env-3.5.3) gdrive_to_commons/$
```
All the following commands are run in this environment and in this directory only.
7. Install dependencies by running the following command:
```
(gdrive-env-3.5.3) gdrive_to_commons/$ pip install -r requirements.txt
```
8. We use pre-commit hooks to format code. install precommit framework by running the following command:
`(gdrive-env-3.5.3) gdrive_to_commons/$ pip install pre-commit`
Now, install our pre-commit hooks using:
`(gdrive-env-3.5.3) gdrive_to_commons/$ pre-commit install`
9. There are some `localsettings` you need to have as part of running the server. You can copy a template using:
`(gdrive-env-3.5.3) gdrive_to_commons/$ cp gdrive_to_commons/local_settings_sample.py gdrive_to_commons/local_settings.py`
Few credentials have to be modified in `local_setting.py`
The credentials that are to be pasted in the `local_settings.py` are given in the following link:
https://phabricator.wikimedia.org/P10014.
Paste the Google Drive to Wikimedia Commons Dev credentials in `local_settings.py`10. Run the Django standard runserver steps:
```
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py makemigrations
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py migrate
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py collectstatic
(gdrive-env-3.5.3) gdrive_to_commons/$ python manage.py runserver localhost:8000
```
or even better, run it from pyCharm using your debugger.
Note: Only paste the command after $ in terminal while setting up and do not paste the whole line which might cause error.