8000 Scaffolding of a bare-bones site. Fill in the gaps! · python/pythonineducation.org@b784c81 · GitHub
[go: up one dir, main page]

Skip to content

Commit b784c81

Browse files
committed
Scaffolding of a bare-bones site. Fill in the gaps!
1 parent 85af6da commit b784c81

19 files changed

+404
-1
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.venv
2+
output
3+
.sass-cache
4+
*.swp
5+
*.pyc
6+
7+
.DS_Store

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: python
2+
sudo: false
3+
4+
cache:
5+
directories:
6+
- $HOME/.cache/pip
7+
8+
install:
9+
- pip install --disable-pip-version-check --upgrade pip
10+
- pip install -r requirements.txt
11+
12+
script: make test
13+
14+
after_success: make deploy

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.PHONY: help build serve test deploy
2+
3+
help:
4+
@echo 'Makefile for pythonineducation.org'
5+
@echo ''
6+
@echo 'Usage:'
7+
@echo ' make build build the site into the output directory'
8+
@echo ' make serve build the site and serve on port 8000, watching for changes'
9+
@echo ' make test test that site builds, has no broken links, and spells the conference name correctly'
10+
@echo ' make deploy deploy site'
11+
@echo ''
12+
13+
build:
14+
wok
15+
16+
serve:
17+
wok --serve
18+
19+
test:
20+
./pre-flight-checks.sh
21+
22+
deploy:
23+
./deploy.sh

README.rst

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,107 @@
11
pythonineducation.org
22
=====================
33

4-
The pythonineducation.org website
4+
.. image:: https://travis-ci.org/python/pythonineducation.org.svg?branch=master
5+
:target: https://travis-ci.org/python/pythonineducation.org
6+
7+
This is the website for the http://pythonineducation.org/ website. It is hosted
8+
via GitHub Pages.
9+
10+
If you have a suggestion to make, please feel free to create an issue_.
11+
12+
We welcome pull requests for improvements! (Please see CONTRIBUTING.rst_ for
13+
more details).
14+
15+
Development
16+
~~~~~~~~~~~
17+
18+
This site uses wok_. To install wok and other dependencies, run
19+
``pip install -r requirements.txt``. wok currently only works with Python2.7.
20+
21+
wok build the site by assembling several components:
22+
23+
* Pages are found in ``content/``. Pages may be HTML, Markdown_ or reStrcturedText_, and contain some YAML metadata.
24+
* Statuc files are found in ``media/``.
25+
* The various jinja2_ templates for pages can be found in ``templates/``.
26+
27+
To build the site, run ``make build``. This pulls together all the components
28+
into a set of HTML files in ``output/``.
29+
30+
Windows users: you need to run the (extensionless) ``wok`` script in
31+
``c:\pythonxx\scripts``. e.g. ``py -2 c:\python27\scripts\wok``.
32+
33+
Alternatively, if you run ``make serve``, wok will build the site, serve the
34+
built site on port 8000, and watch for changes.
35+
36+
Windows users: you ned to run the (extensionless) ``work`` script with the
37+
``--serve`` parameter in ``c:\pythonxx\scripts``. e.g.
38+
``py -2 c:\python27\scripts\wok --serve``.
39+
40+
You can test that the site contains no broken links and that various common
41+
mis-spellings are caught correctly (hint, it's a "BBC micro:bit" for example)
42+
by running ``make test``.
43+
44+
Travis will test branches, and branches won't get merged without review and
45+
passing tests, so dive in!
46+
47+
48+
Internationalisation
49+
~~~~~~~~~~~~~~~~~~~~
50+
51+
Python is used all over the world. Education takes place all over the world!
52+
53+
This site should be available to people for whom English is not a native
54+
language.
55+
56+
As a result and *from the very start of our development process* we have made
57+
it easy for contributions to be made in different languages. Here's how it
58+
works:
59+
60+
* Each language specific version of the site lives under a path containing the
61+
`ISO 639-1 <https://en.wikipedia.org/wiki/ISO_639-1>`_ language code. For
62+
example, the English version is found under the ``/en`` path whereas the
63+
German version is under the ``/de`` path.
64+
* In the ``template/`` directory of this repository as the page templates for
65+
different languages. All inherit from the ``base.html`` template. They are
66+
named ``page_XX.html`` where XX is the appropriate ISO 639-1 code for the
67+
language for which the template is used. For example, English content uses
68+
the ``page_en.html`` template whereas the German template is
69+
``page_de.html``. These pages should contain the localised header and footer.
70+
* In the ``content/`` directory of this repository are directories named after
71+
the ISO 639-1 language code. They contain the content for this website in
72+
the langauge referenced by the language code in the name of the directory.
73+
For example, the English content is found in the ``content/en/`` directory
74+
whereas the German content is in ``content/de/``. You must make sure that
75+
the ``type`` field in the YAML header for the content is set to the correct
76+
page template for the language.
77+
* If in doubt, just look at what happens in the English version of the site and
78+
adapt to the desired language.
79+
80+
Deployment
81+
~~~~~~~~~~
82+
83+
The site is hosted as a Project Page on GitHub Pages, and so it is the
84+
``gh-pages`` branch of the repository that gets served. wok generates the site
85+
in the ``output/`` directory, and Travis is configured to push any changes to
86+
the ``output/`` directory to this branch. See ``deploy.sh`` for details.
87+
88+
This should be done automatically by Travis after it has built the ``master``
89+
branch, but in case this does not happen, somebody with commit access to the
90+
repository can run ``make deploy``.
91+
92+
When setting up Travis to run this initially you must provide an OAuth token
93+
for authentication in the ``GH_TOKEN`` env var. To do this create a
94+
`Personal Access Token on GitHub <https://github.com/settings/tokens>`_ then
95+
create the ``GH_TOKEN`` key pair on the Travis
96+
`settings page <https://travis-ci.org/python/pythonineducation.org/settings>`_
97+
for the project.
98+
99+
Note: this is tied to a single user on GitHub, however any other GitHub user
100+
with valid permissions can replace the key on Travis.
101+
102+
.. _wok: http://wok.mythmon.com/
103+
.. _Markdown: https://pythonhosted.org/Markdown/
104+
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
105+
.. _jinja2: http://jinja.pocoo.org/
106+
.. _issue: https://github.com/python/pythonineducation.org/issues
107+
.. _CONTRIBUTING.rst: ./CONTRIBUTING.rst

config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
url_pattern: /{slug}/index.html

content/CNAME

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
url: CNAME
2+
type: none
3+
---
4+
pythonineducation.org

content/de/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type: page_de
2+
category: home
3+
slug: index
4+
url: /de/index.html
5+
title: Python in der Bildung
6+
---
7+
8+
#Demnächst!#
9+
10+
(Auf Deutsch)

content/en/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type: page_en
2+
category: home
3+
slug: index
4+
url: /en/index.html
5+
title: Python in Education
6+
---
7+
8+
#Coming soon!#
9+
10+
(In English)

content/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type: page_en
2+
slug: home
3+
url: index.html
4+
title: Python in Education
5+
---
6+
7+
#Coming soon!#

deploy.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [[ $TRAVIS = "true" ]]; then
6+
if [[ $TRAVIS_BRANCH != "master" || $TRAVIS_PULL_REQUEST != "false" ]]; then
7+
# Bail out if Travis is building a branch or is building a Pull Request.
8+
echo "Not deploying!"
9+
exit 0
10+
fi
11+
12+
REPO_URL="https://PYTHON-USER@github.com/python/pythonineducation.org"
13+
14+
# Set up credentials for pushing to GitHub. $GH_TOKEN is configured via Travis web UI.
15+
git config --global credential.helper "store --file=$TRAVIS_BUILD_DIR/git-credentials"
16+
echo "https://PYTHON-USER:$GH_TOKEN@github.com" > $TRAVIS_BUILD_DIR/git-credentials
17+
18+
# Set up config for committing.
19+
git config --global user.name "Travis"
20+
git config --global user.email "no-reply@python.org"
21+
else
22+
REPO_URL="git@github.com:python/pythonineducation.org.git"
23+
fi
24+
25+
echo "Deploying!"
26+
27+
# Remove output directory and replace it with the current tip of the gh-pages branch.
28+
rm -rf output
29+
git clone $REPO_URL --branch gh-pages --single-branch output
30+
31+
# Update the output directory with recent changes.
32+
make build
33+
34+
# Add, commit, and push any changes.
35+
cd output
36+
git add .
37+
git commit -m "[skip ci] Auto-commit. Built latest changes."
38+
git push $REPO_URL gh-pages
39+
40+
# Clean up.
41+
rm -rf .git

media/css/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* CSS HERE */

media/favicon.ico

14.7 KB
Binary file not shown.

pre-flight-checks.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
ERRORS=()
4+
5+
###
6+
# Check that site can be built.
7+
###
8+
9+
echo " *** Checking that site can be built."
10+
11+
wok --serve >/dev/null 2>&1 &
12+
WOK_PID=$!
13+
14+
if [[ $? -eq 0 ]]; then
15+
echo " *** Site built ok."
16+
else
17+
echo " *** Site could not be built."
18+
exit 1
19+
fi
20+
21+
###
22+
# Wait for server to start.
23+
###
24+
25+
sleep 5
26+
curl "http://localhost:8000" >/dev/null 2>&1
27+
28+
if [[ $? -ne 0 ]]; then
29+
echo " *** Server is not running."
30+
exit 1
31+
fi
32+
33+
###
34+
# Check that no links are broken.
35+
###
36+
37+
# TODO reinstate this
38+
39+
#echo " *** Checking that no links are broken."
40+
41+
#linkchecker --no-status --no-warnings --check-extern "http://localhost:8000"
42+
43+
#if [[ $? -ne 0 ]]; then
44+
# ERRORS+=("Broken links found on site")
45+
#fi
46+
47+
###
48+
# Check that common names are spelt correctly.
49+
###
50+
51+
echo " *** Checking that common names are spelt correctly"
52+
53+
grep -e "MicroBit" -e "Microbit" -e "microbit" -e "microBit" --line-number --recursive --include "*.html" output | grep -v https://microbit.co.uk
54+
55+
if [[ $? -eq 0 ]]; then
56+
ERRORS+=("Spelling mistaik detected. :-)")
57+
fi
58+
59+
kill $WOK_PID
60+
61+
if [[ ${#ERRORS[@]} -eq 0 ]]; then
62+
echo " *** All pre-flight checks passed!"
63+
exit 0
64+
else
65+
echo " *** The following pre-flight check(s) failed:"
66+
for error in "${ERRORS[@]}"; do
67+
echo " - $error"
68+
done
69+
exit 1
70+
fi

requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wok==1.1.1

requirements.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# This file is autogenerated by pip-compile
3+
# Make changes in requirements.in, then run this to update:
4+
#
5+
# pip-compile requirements.in
6+
#
7+
awesome-slugify==1.4 # via wok
8+
docutils==0.8.1 # via wok
9+
Jinja2==2.6 # via wok
10+
Markdown==2.1.1 # via wok
11+
py==1.4.31 # via pytest
12+
Pygments==1.4 # via wok
13+
pytest==2.5.2 # via wok
14+
PyYAML==3.10 # via wok
15+
regex==2016.3.2 # via awesome-slugify
16+
Unidecode==0.4.19 # via awesome-slugify
17+
wok==1.1.1

templates/base.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<!--
3+
{% block secret %}{% endblock %}
4+
--!>
5+
<html>
6+
<head>
7+
<meta charset="utf-8">
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
9+
<meta http-equiv="X-Clacks-Overhead" content="GNU John Pinner">
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
12+
<title>{{ page.title }}</title>
13+
14+
<link href="/css/styles.css" rel="stylesheet" />
15+
<!--[if lt IE 9]>
16+
<script src="/js/modernizr.js"></script>
17+
<![endif]-->
18+
</head>
19+
<body class="home">
20+
{% block header %}{% endblock %}
21+
{% block content %}{% endblock %}
22+
{% block footer %}{% endblock %}
23+
</body>
24+
<!-- Python Powered! -->
25+
</html>

templates/none.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ page.content }}

templates/page_de.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% extends "base.html" %}
2+
3+
{% block secret %}
4+
Herzliche Glückwünsche! Sie haben "the source" gefunden. :-)
5+
6+
Sie sind offensichtlich neugierig ~ und das ist eine gute Sache. Wenn du wissen
7+
willst wie wirklich diese Seite funktioniert, sollten Sie besuchen:
8+
9+
https://github.com/python/pythonineducation.org
< 427E code>10+
11+
Wir freuen uns über Beiträge von jedem, egal, wer Sie sind. Wenn du bist
12+
denken, "aber sie bedeuten mir nicht", MEINEN WIR iHNEN BESONDERS. Für mehr
13+
Informationen finden Sie unter:
14+
15+
https://github.com/python/pythonineducation.org/blob/master/CONTRIBUTING.rst
16+
17+
Die besten Wünsche!
18+
{% endblock %}
19+
20+
{% block header %}
21+
<header>
22+
<!-- Ein Header auf Deutsch -->
23+
</header>
24+
{% endblock %}
25+
26+
{% block content %}
27+
{{ page.content }}
28+
{% endblock %}
29+
30+
{% block footer %}
31+
<footer>
32+
<!-- Eine Fußzeile auf Deutsch -->
33+
</footer>
34+
{% endblock %}

0 commit comments

Comments
 (0)
0