Skip to content

Commit

Permalink
Use Pelican to generate the site and blog
Browse files Browse the repository at this point in the history
- This PR doesn't change the look and feel of the site
  at all. It just changes how it is built.
- Use Pelican with a custom theme
- publishers.html -> publishers/, advertisers.html -> advertisers/
- Still uses GitHub actions to generate and deploy the site
- Blog isn't enabled yet but can be enabled by uncommenting
  a line in `pelicanconf.py`
  • Loading branch information
davidfischer committed Aug 11, 2020
1 parent 119a8bd commit 2e29b8f
Show file tree
Hide file tree
Showing 44 changed files with 4,160 additions and 1,052 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,41 @@ on:

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Install
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Build static assets
run: |
npm install
npm run dist
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pelican-${{ hashFiles('requirements.txt') }}
restore-keys: |
pelican-
- name: Install Pelican
run: |
pip install -r requirements.txt
- name: Run Pelican
id: run-pelican
run: |
pelican content --output docs --settings publishconf.py
- name: Install SSH Client
uses: webfactory/[email protected] # This step installs the ssh client into the workflow run. There's many options available for this on the action marketplace.
with:
Expand All @@ -30,6 +52,6 @@ jobs:
with:
BASE_BRANCH: master
BRANCH: gh-pages
FOLDER: www
FOLDER: output
CLEAN: true
SSH: true # SSH must be set to true so the deploy action knows which protocol to deploy with.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ docs/build/*
node_modules

# Specific to ethicalads.io
www/bundle
output
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: 'ethicalads-theme/.*$'
- id: trailing-whitespace
exclude: 'ethicalads-theme/.*$'
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
# Since the pre-commit runs on a file by file basis rather than a whole project,
# The excludes in pyproject.toml are ignored
exclude: migrations
language_version: python3
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.2
hooks:
- id: reorder-python-imports
language_version: python3
61 changes: 56 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
EthicalAds
==========

This is a landing page for EthicalAds.io,
the developer network coming soon from Read the Docs.
This is a landing page for EthicalAds.io, the developer network from Read the Docs.


Building the site
-----------------
Site details
------------

The site is built as a static site using `Pelican <https://blog.getpelican.com/>`_ and hosted by `GitHub pages <https://pages.github.com/>`_.
The site is automatically built and updated when there are commits on the master branch although it can take up to 5 minutes.


Building the site locally
~~~~~~~~~~~~~~~~~~~~~~~~~

You can build the site HTML and serve it locally with:

.. code-block:: bash
$ pip install -r requirements.txt
$ pre-commit install # Install a code style pre-commit hook
$ inv rebuild # build one time
$ inv regenerate # regenerate the site whenever you modify a page/post
$ inv serve # serve the site at http://localhost:8000
Building static assets
~~~~~~~~~~~~~~~~~~~~~~

Built static assets are checked into the repository and you only need to rebuild them
if you modify files under ``static-src/``.

.. code-block:: bash
$ npm install
$ npm run build # use "npm run dist" for minified builds
The static content appears in www/bundle
The static content appears in ``ethicalads-theme/static/``


Deploying the site
Expand All @@ -26,3 +49,31 @@ It is served by GitHub pages at https://www.ethicalads.io.
For more details on the deployment actions, see workflows_.

.. _workflows: https://github.com/readthedocs/ethicalads.io/tree/master/.github/workflows


Developing the site
-------------------

Writing pages
~~~~~~~~~~~~~

Pages should be saved under ``content/pages/``.
By default, they use the ``ethicalads-theme/templates/page.html`` template but that can be overridden.


Writing blog posts
~~~~~~~~~~~~~~~~~~

Blog posts should be saved under ``content/posts/``.


Updating the design
~~~~~~~~~~~~~~~~~~~

The styles and scripts for the site are built by Webpack from the sources in ``static-src/``.
The HTML templates for the site live under ``ethical-ads-theme/``
and extend from Pelican's `simple theme`_.

The EthicalAds theme was not designed to work with relative URLs.

.. _simple theme: https://github.com/getpelican/pelican/tree/master/pelican/themes/simple/templates
3 changes: 3 additions & 0 deletions content/pages/advertisers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Title: Advertisers
description: Reach a millions of engaged developers with relevant advertising that respects their privacy. Whether you are recruiting talent or promoting your products, EthicalAds is the best channel to reach your target audience.
template: ea/advertisers
8 changes: 8 additions & 0 deletions content/pages/contact-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Title: Whoops - there was a problem reaching us
Slug: contact-error
description: There was a problem reaching us so please email us directly
status: hidden

Our email system couldn't process your note to us. Please email us at [email protected] and we'll get back to you as soon as we can.

[Learn more about EthicalAds](/)
8 changes: 8 additions & 0 deletions content/pages/contact-success.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Title: We got your message
Slug: contact-success
description: We got your message and we'll get back to you as soon as we can.
status: hidden

Thanks for contacting us and we'll get back to you as soon as we can.

[Learn more about EthicalAds](/)
5 changes: 5 additions & 0 deletions content/pages/homepage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Title: Home page
save_as: index.html
template: ea/homepage
status: hidden
description: EthicalAds: A developer-focused, privacy-obsessed ad network from the fine folks at Read the Docs
Loading

0 comments on commit 2e29b8f

Please sign in to comment.