diff --git a/README.md b/README.md index 3f3e4d5c..c44acbd2 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,19 @@ GitHub Cards is available on jsdelivr now. Use widget hosted on jsdelivr: ``` +## Building + +If you want to work on this project locally, you'll first need to clone it `git clone https://github.com/lepture/github-cards` + +Then you'll need to install a few build dependencies: + +* [python3](https://www.python.org/) (if not already installed, through your favorite package manager) +* [npm](https://www.npmjs.com/) (through your favorite package manager, along with Node.js) +* [uglifyjs](https://www.npmjs.com/package/uglify-js) through `sudo npm install -g uglify-js` +* [cleancss](https://www.npmjs.com/package/clean-css-cli) through `sudo npm install -g clean-css-cli` + +Once all of this is installed, you should be all set to build the site ! Use `make build` to do so. You can then view the site by opening _\_site/index.html_ in your browser of choice, and start making changes (you'll need to rebuild the site every time you change the files in _src/_) + ## Contribution This project is under the BSD License. diff --git a/generate.py b/generate.py index 018a28a4..28189e8f 100755 --- a/generate.py +++ b/generate.py @@ -47,15 +47,15 @@ def create_card(theme): css = shell(['cleancss', 'theme/%s.css' % theme]) - with open('src/card.js', 'rb') as f: + with open('src/card.js', 'r') as f: content = f.read() content += GA % 'UA-21475122-2' - js = shell(['uglifyjs', '-m'], content) + js = shell(['uglifyjs', '-m'], content.encode()) - out = html % (css, tinyhtml(template), js) + out = html % (css.decode(), tinyhtml(template), js.decode()) with open('cards/%s.html' % theme, 'wb') as f: - f.write(out) + f.write(out.encode()) def create_widget(): @@ -71,7 +71,7 @@ def create_widget(): 'var base = "%s";' % url ) - js = shell(['uglifyjs', '-m'], content) + js = shell(['uglifyjs', '-m'], content.encode()) with open('jsdelivr/widget.js', 'wb') as f: f.write(js)