Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make docker env for development, update dependencies [WIP] #795

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine:3.16

RUN apk --no-cache add python3 py3-pip asciidoctor git build-base py3-psutil python3-dev libffi-dev
RUN pip install "Nikola[extras]" python-Levenshtein==0.12.1 pathlib beautifulsoup4 markdown && rm -rf /root/.cache/

WORKDIR /nikola
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ The `tutorials` folder is structured with a first level of folders that represen

The `documentation` folder contains the OF API reference and are also in markdown format. This docs are generated from the code but the `description` field in every class, function or var can be edited directly in the markdown files.

## Setting up the site to build locally

This site is built using [nikola](https://getnikola.com). There's some scripts in the root folder to make it easier to install and use.
## Setting up the site to build locally using Docker

1. First, if installing on Mac OS-X, make sure the Xcode command lines tools have been installed:
This site is built using [nikola](https://getnikola.com).
There's some scripts in the `bin/` folder that use Docker
to make it easier to install and use.
(Tested on MacOS).

```bash
xcode-select --install
```
and then install the following packages (If you do not have brew installed you can grab it from [brew.sh](http://brew.sh/)):
* Pre-reqs: a working [Docker](https://www.docker.com/get-started/)
environment and *nix shell
* Build an image (alpine linux, python3, nikola) with
`./bin/build_docker.sh` (delete the image with `./bin/rm_docker.sh`)
* Build the site and serve it on `http://localhost:8000/` with `./nikola_auto_build.sh`
* (Build the site only with `./nikola_build.sh`)
* (Serve the site on `http://localhost:8000/` with `./nikola_serve.sh`)

```bash
brew install python3
sudo easy_install pip
brew linkapps python3
```

2. From the ofSite source directory, run ./install.sh which installs nikola and all the needed dependencies. (This has only been tested on linux and OS-X).
## Setting up the site to build locally

3. Please make sure the symbol link `~/nikola/.Python` to python3 path is correct before you run `install.sh` script.

4. Finally add the following to your .basrc, .bash_profile or .zshrc file:
`export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"`
Expand Down
4 changes: 0 additions & 4 deletions auto_build.sh

This file was deleted.

7 changes: 7 additions & 0 deletions bin/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_IMAGE_TAG="ofsite/nikola:1.0"

docker build \
-t "${DOCKER_IMAGE_TAG}" \
"${SCRIPT_DIR}/.."
11 changes: 11 additions & 0 deletions bin/nikola_auto_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_IMAGE_TAG="ofsite/nikola:1.0"

docker run \
--rm \
-ti \
-p 127.0.0.1:8000:8000/tcp \
-v "${SCRIPT_DIR}/..:/nikola" \
"${DOCKER_IMAGE_TAG}" \
nikola auto -a 0.0.0.0
11 changes: 11 additions & 0 deletions bin/nikola_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_IMAGE_TAG="ofsite/nikola:1.0"

docker run \
--rm \
-ti \
-p 127.0.0.1:8000:8000/tcp \
-v "${SCRIPT_DIR}/..:/nikola" \
"${DOCKER_IMAGE_TAG}" \
nikola build
11 changes: 11 additions & 0 deletions bin/nikola_serve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_IMAGE_TAG="ofsite/nikola:1.0"

docker run \
--rm \
-ti \
-p 127.0.0.1:8000:8000/tcp \
-v "${SCRIPT_DIR}/..:/nikola" \
"${DOCKER_IMAGE_TAG}" \
nikola serve -a 0.0.0.0
6 changes: 6 additions & 0 deletions bin/rm_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_IMAGE_TAG="ofsite/nikola:1.0"

docker image rm \
"${DOCKER_IMAGE_TAG}"
11 changes: 11 additions & 0 deletions bin/sh_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_IMAGE_TAG="ofsite/nikola:1.0"

docker run \
--rm \
-ti \
-p 127.0.0.1:8000:8000/tcp \
-v "${SCRIPT_DIR}/..:/nikola" \
"${DOCKER_IMAGE_TAG}" \
/bin/ash
4 changes: 0 additions & 4 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@

# If you hate "Filenames with Capital Letters and Spaces.md", you should
# set this to true.
UNSLUGIFY_TITLES = True
FILE_METADATA_UNSLUGIFY_TITLES = True

# Additional metadata that is added to a post when creating a new_post
# ADDITIONAL_METADATA = {}
Expand Down
7 changes: 3 additions & 4 deletions plugins/asciidoc/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Compiler plugin to support the AsciiDoc markup.
Compiler plugin to support the AsciiDoc markup via the original `asciidoc` tool or via `asciidoctor`.

Example usage of Nikola's *path handlers* in Asciidoc:

link:link://slug/demo-page[Click here to go to the demo page]

[More information about AsciiDoc](http://www.methods.co.nz/asciidoc/)


[More information about AsciiDoc](https://asciidoc.org/)

[More information about Asciidoctor](https://asciidoctor.org/)
5 changes: 4 additions & 1 deletion plugins/asciidoc/asciidoc.plugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
Name = asciidoc
Module = asciidoc

[Nikola]
PluginCategory = PageCompiler

[Documentation]
Author = Roberto Alsina
Version = 0.3
Version = 0.6
Website = http://plugins.getnikola.com/#asciidoc
Description = Compile ASCIIDoc into HTML
66 changes: 47 additions & 19 deletions plugins/asciidoc/asciidoc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

# Copyright © 2012-2014 Roberto Alsina and others.

Expand Down Expand Up @@ -30,12 +30,13 @@

"""

import codecs
import io
import os
import shlex
import subprocess

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, write_metadata
from nikola.utils import makedirs, write_metadata

try:
from collections import OrderedDict
Expand All @@ -49,28 +50,55 @@ class CompileAsciiDoc(PageCompiler):
name = "asciidoc"
demote_headers = True

def compile_html(self, source, dest, is_two_file=True):
makedirs(os.path.dirname(dest))
def compile_string(self, data, source_path=None, is_two_file=True, post=None, lang=None):
"""Compile asciidoc into HTML strings."""
binary = self.site.config.get('ASCIIDOC_BINARY', 'asciidoc')
try:
subprocess.check_call((binary, '-b', 'html5', '-s', '-o', dest, source))
except OSError as e:
if e.strreror == 'No such file or directory':
req_missing(['asciidoc'], 'build this site (compile with asciidoc)', python=False)
options = self.site.config.get('ASCIIDOC_OPTIONS', '')
options = shlex.split(options)
command = [binary, '-b', 'html5', '-s'] + options + ['-']
if not is_two_file:
m_data, data = self.split_metadata(data, post, lang)

from nikola import shortcodes as sc
new_data, shortcodes = sc.extract_shortcodes(data)
p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
output = p.communicate(input=new_data.encode('utf8'))[0].decode('utf8')
output, shortcode_deps = self.site.apply_shortcodes_uuid(output, shortcodes, filename=source_path, extra_context={'post': post})
return output, p.returncode, [], shortcode_deps

def compile(self, source, dest, is_two_file=True, post=None, lang=None):
"""Compile the source file into HTML and save as dest."""
makedirs(os.path.dirname(dest))
with io.open(dest, "w+", encoding="utf8") as out_file:
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
output, error_level, deps, shortcode_deps = self.compile_string(data, source, is_two_file, post, lang)
out_file.write(output)
if post is None:
if deps.list:
self.logger.error(
"Cannot save dependencies for post {0} (post unknown)",
source)
else:
post._depfile[dest] += shortcode_deps
if error_level == 0:
return True
else:
return False

def create_post(self, path, **kw):
content = kw.pop('content', 'Write your post here.')
one_file = kw.pop('onefile', False) # NOQA
is_page = kw.pop('is_page', False) # NOQA
metadata = OrderedDict()
"""Create a new post."""
content = kw.pop('content', None)
onefile = kw.pop('onefile', False)
# is_page is not used by create_post as of now.
kw.pop('is_page', False)
metadata = {}
metadata.update(self.default_metadata)
metadata.update(kw)
makedirs(os.path.dirname(path))
if not content.endswith('\n'):
content += '\n'
with codecs.open(path, "wb+", "utf8") as fd:
if one_file:
fd.write("////\n")
fd.write(write_metadata(metadata))
fd.write("////\n")
with io.open(path, "w+", encoding="utf8") as fd:
if onefile:
fd.write(write_metadata(metadata, comment_wrap=('///', '///'), site=self.site, compiler=self))
fd.write(content)
7 changes: 5 additions & 2 deletions plugins/asciidoc/conf.py.sample
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Add the asciidoc compiler to your COMPILERS dict.
COMPILERS["asciidoc"] = ('.asc',)
COMPILERS["asciidoc"] = ['.asc']

# Add asciidoc files to your POSTS, PAGES
POSTS = POSTS + (("posts/*.asc", "posts", "post.tmpl"),)
PAGES = PAGES + (("stories/*.asc", "posts", "post.tmpl"),)
PAGES = PAGES + (("pages/*.asc", "pages", "page.tmpl"),)

# You can choose what command to use for processing.
# For example, you can replace asciidoc with asciidoctor
# Or use the full path to the program.
# ASCIIDOC_BINARY = "asciidoc"

# Specify options to the asciidoc compiler (as a string).
# ASCIIDOC_OPTIONS = ""
3 changes: 2 additions & 1 deletion plugins/asciidoc/requirements-nonpy.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
AsciiDoc::http://www.methods.co.nz/asciidoc/
AsciiDoc::https://asciidoc.org/INSTALL.html
Asciidoctor (alternative)::https://asciidoctor.org/
20 changes: 10 additions & 10 deletions plugins/documentation/documentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,21 @@ def create_docs(self):
clazz.name = clazz.name[:-1]

clazz.detailed_inline_description = relative_urls(clazz.detailed_inline_description)
clazz.detailed_inline_description = markdown(clazz.detailed_inline_description, md_extensions)
clazz.detailed_inline_description = markdown(clazz.detailed_inline_description, extensions=md_extensions)
clazz.detailed_inline_description = of_classes_to_links(clazz.detailed_inline_description, classes_simple_name, module_lookup)

clazz.reference = relative_urls(clazz.reference)
clazz.reference = markdown(clazz.reference, md_extensions)
clazz.reference = markdown(clazz.reference, extensions=md_extensions)
clazz.reference = of_classes_to_links(clazz.reference, classes_simple_name, module_lookup)

# methods in class
for function in clazz.function_list:
function.description = relative_urls(function.description)
function.description = markdown(function.description, md_extensions)
function.description = markdown(function.description, extensions=md_extensions)
function.description = of_classes_to_links(function.description, classes_simple_name, module_lookup)

function.inlined_description = relative_urls(function.inlined_description)
function.inlined_description = markdown(function.inlined_description, md_extensions)
function.inlined_description = markdown(function.inlined_description, extensions=md_extensions)
function.inlined_description = of_classes_to_links(function.inlined_description, classes_simple_name, module_lookup)
for lang in self.kw['translations']:
content_js[lang] += method_to_js(function, clazz, self.site, lang)
Expand All @@ -263,11 +263,11 @@ def filter_out_empty(class_name):
functions_file = markdown_file.getfunctionsfile(clazz.name)
for function in functions_file.function_list:
function.description = relative_urls(function.description)
function.description = markdown(function.description, md_extensions)
function.description = markdown(function.description, extensions=md_extensions)
function.description = of_classes_to_links(function.description, classes_simple_name, module_lookup)

function.inlined_description = relative_urls(function.inlined_description)
function.inlined_description = markdown(function.inlined_description, md_extensions)
function.inlined_description = markdown(function.inlined_description, extensions=md_extensions)
function.inlined_description = of_classes_to_links(function.inlined_description, classes_simple_name, module_lookup)
for lang in self.kw['translations']:
content_js[lang] += function_to_js(function, functions_file, self.site, lang)
Expand Down Expand Up @@ -337,11 +337,11 @@ def filter_out_empty(class_name):

for function in functions_file.function_list:
function.description = relative_urls(function.description)
function.description = markdown(function.description, md_extensions)
function.description = markdown(function.description, extensions=md_extensions)
function.description = of_classes_to_links(function.description, classes_simple_name, module_lookup)

function.inlined_description = relative_urls(function.inlined_description)
function.inlined_description = markdown(function.inlined_description, md_extensions)
function.inlined_description = markdown(function.inlined_description, extensions=md_extensions)
function.inlined_description = of_classes_to_links(function.inlined_description, classes_simple_name, module_lookup)
for lang in self.kw['translations']:
content_js[lang] += function_to_js(function, functions_file, self.site, lang)
Expand Down Expand Up @@ -394,7 +394,7 @@ def filter_out_empty(class_name):
module_intro_file = open(module_intro)
module_intro_content = module_intro_file.read()
module_subtitles[module] = module_intro_content.splitlines()[0].strip('##').strip(' ')
module_intro_content = markdown(module_intro_content, md_extensions)
module_intro_content = markdown(module_intro_content, extensions=md_extensions)
for lang in self.kw['translations']:
context = {}
context["site_url"] = self.site.config["SITE_URL"]
Expand Down Expand Up @@ -440,7 +440,7 @@ def filter_out_empty(class_name):
for key in self.site.GLOBAL_CONTEXT.keys():
if isinstance(self.site.GLOBAL_CONTEXT[key], str):
docs_intro = docs_intro.replace('${' + key + '}', self.site.GLOBAL_CONTEXT[key])
docs_intro = markdown(docs_intro, md_extensions)
docs_intro = markdown(docs_intro, extensions=md_extensions)
context = {}
context["lang"] = lang
context["site_url"] = self.site.config["SITE_URL"]
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions serve.sh

This file was deleted.

2 changes: 1 addition & 1 deletion themes/openframeworks/parent
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bootstrap3
bootstrap4