diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9ecdbb5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 GitLab Pages examples + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1e24e62 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +PY?=python3 +PELICAN?=pelican +PELICANOPTS= + +BASEDIR=$(CURDIR) +INPUTDIR=$(BASEDIR)/content +OUTPUTDIR=$(CURDIR)/output +CONFFILE=$(BASEDIR)/pelicanconf.py +PUBLISHCONF=$(BASEDIR)/publishconf.py + + +DEBUG ?= 0 +ifeq ($(DEBUG), 1) + PELICANOPTS += -D +endif + +RELATIVE ?= 0 +ifeq ($(RELATIVE), 1) + PELICANOPTS += --relative-urls +endif + +help: + @echo 'Makefile for a pelican Web site ' + @echo ' ' + @echo 'Usage: ' + @echo ' make html (re)generate the web site ' + @echo ' make clean remove the generated files ' + @echo ' make regenerate regenerate files upon modification ' + @echo ' make publish generate using production settings ' + @echo ' make serve [PORT=8000] serve site at http://localhost:8000' + @echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 ' + @echo ' make devserver [PORT=8000] serve and regenerate together ' + @echo ' make ssh_upload upload the web site via SSH ' + @echo ' make rsync_upload upload the web site via rsync+ssh ' + @echo ' ' + @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html ' + @echo 'Set the RELATIVE variable to 1 to enable relative urls ' + @echo ' ' + +html: + $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) + +clean: + [ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR) + +regenerate: + $(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) + +serve: +ifdef PORT + $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) +else + $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) +endif + +serve-global: +ifdef SERVER + $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) -b $(SERVER) +else + $(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) -b 0.0.0.0 +endif + + +devserver: +ifdef PORT + $(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) -p $(PORT) +else + $(PELICAN) -lr $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) +endif + +publish: + $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS) + + +.PHONY: html help clean regenerate serve serve-global devserver publish diff --git a/README.md b/README.md new file mode 100644 index 0000000..b135cc9 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +![Build Status](https://gitlab.com/pages/pelican/badges/master/build.svg) + +---- + +Example [Pelican] website using GitLab Pages. Check the resulting website here: + +Learn more about GitLab Pages at https://pages.gitlab.io and the [official +documentation](https://docs.gitlab.com/ce/user/project/pages/), including +[how to fork a project like this one to get started from](https://docs.gitlab.com/ee/user/project/pages/getting_started_part_two.html#fork-a-project-to-get-started-from). + +--- + + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [GitLab CI](#gitlab-ci) +- [Building locally](#building-locally) +- [GitLab User or Group Pages](#gitlab-user-or-group-pages) +- [Did you fork this project?](#did-you-fork-this-project) +- [Troubleshooting](#troubleshooting) + + + +## GitLab CI + +This project's static Pages are built by [GitLab CI][ci], following the steps +defined in the file [`.gitlab-ci.yml`](.gitlab-ci.yml). + +## Building locally + +To work locally with this project, you'll have to follow the steps below: + +1. Fork, clone or download this project +1. [Install][] Pelican +1. Regenerate and serve on port 8000: `make devserver` +1. Add content + +Read more at Pelican's [documentation]. + +## GitLab User or Group Pages + +To use this project as your user/group website, you will need to perform +some additional steps: + +1. Rename your project to `namespace.gitlab.io`, where `namespace` is +your `username` or `groupname`. This can be done by navigating to your +project's **Settings > General (Advanced)**. + +2. Adjust Pelican's `SITEURL` configuration setting in `publishconf.py` to +the new URL (e.g. `https://namespace.gitlab.io`) + +Read more about [GitLab Pages for projects and user/group websites][pagesdoc]. + +## Did you fork this project? + +If you forked this project for your own use, please go to your project's +**Settings** and remove the forking relationship, which won't be necessary +unless you want to contribute back to the upstream project. + +## Troubleshooting + +1. CSS is missing! That means two things: + + Either that you have wrongly set up the CSS URL in your templates, or + your static generator has a configuration option that needs to be explicitly + set in order to serve static assets under a relative URL. + +[ci]: https://about.gitlab.com/gitlab-ci/ +[pelican]: http://blog.getpelican.com/ +[install]: https://docs.getpelican.com/en/stable/install.html +[documentation]: http://docs.getpelican.com/ +[pagesdoc]: https://docs.gitlab.com/ce/user/project/pages/getting_started_part_one.html diff --git a/SparkleShare.txt b/SparkleShare.txt deleted file mode 100644 index 1258e1d..0000000 --- a/SparkleShare.txt +++ /dev/null @@ -1,9 +0,0 @@ -Congratulations, you've successfully created a SparkleShare repository! - -Any files you add or change in this folder will be automatically synced to -ssh://git@nosignal.hopto.org/doohoyi/pelican-site.git and everyone connected to it. - -SparkleShare is an Open Source software program that helps people collaborate and -share files. If you like what we do, consider buying us a beer: http://www.sparkleshare.org/ - -Have fun! :) diff --git a/content/posts/2016-gitlab-pages.md b/content/posts/2016-gitlab-pages.md new file mode 100644 index 0000000..5ec7e02 --- /dev/null +++ b/content/posts/2016-gitlab-pages.md @@ -0,0 +1,11 @@ +Title: Pelican on GitLab Pages! +Date: 2016-03-25 +Category: GitLab +Tags: pelican, gitlab +Slug: pelican-on-gitlab-pages + +This site is hosted on GitLab Pages! + +The source code of this site is at . + +Learn about GitLab Pages at . diff --git a/pelicanconf.py b/pelicanconf.py new file mode 100644 index 0000000..5b708d2 --- /dev/null +++ b/pelicanconf.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +AUTHOR = 'thedude' +SITENAME = 'Example Pelican website using GitLab Pages!' +SITEURL = '' + +PATH = 'content' +OUTPUT_PATH = 'public' + +TIMEZONE = 'Europe/Athens' + +DEFAULT_LANG = 'en' + +# Feed generation is usually not desired when developing +FEED_ALL_ATOM = None +CATEGORY_FEED_ATOM = None +TRANSLATION_FEED_ATOM = None +AUTHOR_FEED_ATOM = None +AUTHOR_FEED_RSS = None + +# Blogroll +LINKS = (('Pelican', 'http://getpelican.com/'), + ('Python.org', 'http://python.org/'), + ('Jinja2', 'http://jinja.pocoo.org/'), + ('You can modify those links in your config file', '#'),) + +# Social widget +SOCIAL = (('You can add links in your config file', '#'), + ('Another social link', '#'),) + +DEFAULT_PAGINATION = 5 + +# Uncomment following line if you want document-relative URLs when developing +#RELATIVE_URLS = True + +# THEME +THEME = "/home/admin/pelican-themes/graymill" diff --git a/publishconf.py b/publishconf.py new file mode 100644 index 0000000..ffca1a1 --- /dev/null +++ b/publishconf.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +# This file is only used if you use `make publish` or +# explicitly specify it as your config file. + +import os +import sys +sys.path.append(os.curdir) +from pelicanconf import * + +SITEURL = '/site/ci/pelican' +RELATIVE_URLS = False + +FEED_ALL_ATOM = 'feeds/all.atom.xml' +CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml' + +DELETE_OUTPUT_DIRECTORY = True + +# Following items are often useful when publishing + +#DISQUS_SITENAME = "" +#GOOGLE_ANALYTICS = "" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b20ad65 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pelican ~= 4.1.0 +markdown +typogrify diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..354b554 --- /dev/null +++ b/tasks.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- + +import os +import shutil +import sys +import datetime + +from invoke import task +from invoke.util import cd +from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer +from pelican.settings import DEFAULT_CONFIG, get_settings_from_file + +SETTINGS_FILE_BASE = 'pelicanconf.py' +SETTINGS = {} +SETTINGS.update(DEFAULT_CONFIG) +LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE) +SETTINGS.update(LOCAL_SETTINGS) + +CONFIG = { + 'settings_base': SETTINGS_FILE_BASE, + 'settings_publish': 'publishconf.py', + # Output path. Can be absolute or relative to tasks.py. Default: 'output' + 'deploy_path': SETTINGS['OUTPUT_PATH'], + # Port for `serve` + 'port': 8000, +} + +@task +def clean(c): + """Remove generated files""" + if os.path.isdir(CONFIG['deploy_path']): + shutil.rmtree(CONFIG['deploy_path']) + os.makedirs(CONFIG['deploy_path']) + +@task +def build(c): + """Build local version of site""" + c.run('pelican -s {settings_base}'.format(**CONFIG)) + +@task +def rebuild(c): + """`build` with the delete switch""" + c.run('pelican -d -s {settings_base}'.format(**CONFIG)) + +@task +def regenerate(c): + """Automatically regenerate site upon file modification""" + c.run('pelican -r -s {settings_base}'.format(**CONFIG)) + +@task +def serve(c): + """Serve site at http://localhost:$PORT/ (default port is 8000)""" + + class AddressReuseTCPServer(RootedHTTPServer): + allow_reuse_address = True + + server = AddressReuseTCPServer( + CONFIG['deploy_path'], + ('', CONFIG['port']), + ComplexHTTPRequestHandler) + + sys.stderr.write('Serving on port {port} ...\n'.format(**CONFIG)) + server.serve_forever() + +@task +def reserve(c): + """`build`, then `serve`""" + build(c) + serve(c) + +@task +def preview(c): + """Build production version of site""" + c.run('pelican -s {settings_publish}'.format(**CONFIG)) + +@task +def livereload(c): + """Automatically reload browser tab upon file modification.""" + from livereload import Server + build(c) + server = Server() + # Watch the base settings file + server.watch(CONFIG['settings_base'], lambda: build(c)) + # Watch content source files + content_file_extensions = ['.md', '.rst'] + for extension in content_file_extensions: + content_blob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension) + server.watch(content_blob, lambda: build(c)) + # Watch the theme's templates and static assets + theme_path = SETTINGS['THEME'] + server.watch('{}/templates/*.html'.format(theme_path), lambda: build(c)) + static_file_extensions = ['.css', '.js'] + for extension in static_file_extensions: + static_file = '{0}/static/**/*{1}'.format(theme_path, extension) + server.watch(static_file, lambda: build(c)) + # Serve output path on configured port + server.serve(port=CONFIG['port'], root=CONFIG['deploy_path']) + + +@task +def publish(c): + """Publish to production via rsync""" + c.run('pelican -s {settings_publish}'.format(**CONFIG)) + c.run( + 'rsync --delete --exclude ".DS_Store" -pthrvz -c ' + '{} {production}:{dest_path}'.format( + CONFIG['deploy_path'].rstrip('/') + '/', + **CONFIG)) +