Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/build-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
run: |
. nikola/bin/activate
nikola build
python utils/check_documentation_urls.py output

- name: Pack output
run: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ If, on osx, you receive this error: `FileNotFoundError: [Errno 2] No such file o

**./serve.sh** : Starts a local web server that serves the site and opens it in the browser.

Builds default to `https://openframeworks.cc/` for absolute links. For a local preview with localhost URLs, explicitly set `OFSITE_SITE_URL=http://localhost:8000/` when running `nikola build`. Production builds must use the public URL.

If you plan to do a big modifications like contribute a translation the easiest is to leave the 2 last scripts running and just edit the content files and the site will automatically get refreshed.

## Documentation-style markdown
Expand Down
6 changes: 5 additions & 1 deletion build_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ if [ -z "$SRC" ]; then
echo nikola
. nikola/bin/activate
#nikola clean 2>> $LOG
nikola build 2>> $LOG
OFSITE_SITE_URL=https://openframeworks.cc/ nikola build 2>> $LOG
ret=$?
if [ "$ret" -eq 0 ]; then
python utils/check_documentation_urls.py output 2>> $LOG
ret=$?
fi
if [ $ret -ne 0 ]
then
SUBJECT="Failed building site"
Expand Down
13 changes: 6 additions & 7 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import time
import markdown
import socket
import hashlib

# !! This is the configuration of Nikola. !! #
# !! You should edit it to your liking. !! #
Expand All @@ -24,12 +24,7 @@
BLOG_TITLE = "openFrameworks" # (translatable)
# This is the main URL for your site. It will be used
# in a prominent link. Don't forget the protocol (http/https)!
if os.environ.get("OFSITE_SITE_URL"):
SITE_URL = os.environ["OFSITE_SITE_URL"]
elif socket.gethostbyname(socket.gethostname()) == socket.gethostbyname('openframeworks.cc'):
SITE_URL = "https://openframeworks.cc/"
else:
SITE_URL = "http://localhost:8000/"
SITE_URL = os.environ.get("OFSITE_SITE_URL") or "https://openframeworks.cc/"
# This is the URL where Nikola's output will be deployed.
# If not set, defaults to SITE_URL
# BASE_URL = "http://openframeworks.cc/"
Expand Down Expand Up @@ -1249,7 +1244,11 @@

# Put in global_context things you want available on all your templates.
# It can be anything, data, functions, modules, etc.
with open(os.path.join(os.path.dirname(__file__), "themes/openframeworks/assets/css/style.css"), "rb") as _stylesheet:
STYLESHEET_VERSION = hashlib.sha256(_stylesheet.read()).hexdigest()[:12]

GLOBAL_CONTEXT = {
"stylesheet_version": STYLESHEET_VERSION,
"currentVersion": "0.12.1",
"breaking": False,
"majorVersion": "0.12.1",
Expand Down
19 changes: 12 additions & 7 deletions themes/openframeworks/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1670,21 +1670,26 @@ table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inh
/* Download platform groups. */
.download-platform-group {
clear: both;
background: #eee;
border: 1px solid #ddd;
padding: 24px;
margin: 0 0 20px;
margin: 0 0 30px;
box-sizing: border-box;
}
.download-platform-group > h2 { margin-top: 0; }
.download-platform-group > h2 { margin: 0 0 16px; }
.download-platform-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 24px;
gap: 16px;
}
.download-platform-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.download-platform-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.download-platform { min-width: 0; overflow-wrap: anywhere; }
.download-platform {
min-width: 0;
padding: 20px;
background: #eee;
border: 1px solid #ddd;
box-sizing: border-box;
overflow-wrap: anywhere;
}
.download-platform > h3 { margin-top: 0; }
.download-platform p { margin: 0 0 10px; }
.download-target-note { font-size: 0.9em; margin-bottom: 0; }
.download-nightly { clear: both; padding-top: 12px; }
Expand Down
2 changes: 1 addition & 1 deletion themes/openframeworks/templates/base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ${set_locale(lang)}
<script src="/assets/js/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

<link rel="stylesheet" type="text/css" href="/assets/css/style.css" media="all" />
<link rel="stylesheet" type="text/css" href="/assets/css/style.css?v=${stylesheet_version}" media="all" />

<link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>

Expand Down
10 changes: 7 additions & 3 deletions themes/openframeworks/templates/documentation_index_block.mako
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## -*- coding: utf-8 -*-
<%page args="module,classes,show_header,subtitle"/>
<%
language_path = translations[lang].strip("./")
documentation_path = ("/" + language_path if language_path else "") + "/documentation/" + module
%>
<div class="documentation_group">
% if show_header:
<div class="documentation_group_head hide">
Expand All @@ -22,7 +26,7 @@
<div class="box">
<ul class="documentation_class">
<!-- class link -->
<li class="docs-module-title"><a href="${site_url}/${'/documentation/' + module + '/' + clazz.name}/" class="documentation_class_link"><strong>${clazz.name}</strong></a>&nbsp;
<li class="docs-module-title"><a href="${documentation_path}/${clazz.name}/" class="documentation_class_link"><strong>${clazz.name}</strong></a>&nbsp;
% if clazz.is_class():
<img src="/icons/class.png" alt="C++ Class"/>
% else:
Expand All @@ -38,7 +42,7 @@
% if len(method.description) <= 1 and len(method.inlined_description) <= 1:
<% htmlclass = htmlclass + " noDoc" %>
% endif
<li class="${htmlclass}"><a href="${site_url}/${'documentation/' + module + '/' + clazz.name}/#!show_${method.name.replace("_","")}" title="${method.name.replace("_","")}" class="documentation_func">${method.name}()</a></li>
<li class="${htmlclass}"><a href="${documentation_path}/${clazz.name}/#!show_${method.name.replace("_","")}" title="${method.name.replace("_","")}" class="documentation_func">${method.name}()</a></li>
<% prevmethod = method.name %>
% endif
% endfor
Expand All @@ -55,7 +59,7 @@
% if len(variable.description) <= 1:
<% htmlclass = htmlclass + " noDoc" %>
% endif
<li class="${htmlclass}"><a href="${site_url}/${'/documentation/' + module + '/' + clazz.name}/#!show_${variable.name}" title="${variable.name}" class="documentation_func">${variable.name}</a></li>
<li class="${htmlclass}"><a href="${documentation_path}/${clazz.name}/#!show_${variable.name}" title="${variable.name}" class="documentation_func">${variable.name}</a></li>
% endif
% endfor
% endif
Expand Down
8 changes: 5 additions & 3 deletions themes/openframeworks/templates/download.mako
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ $(document).ready(function(){

<section class="download-platform-group" id="android">
<h2>Android</h2>
${package_link("Android package (Windows host)", "android_windows", legacy="android_windows")}
<p><a href="../setup/android-studio/">Android Studio setup / NDK 29</a> · <a href="https://developer.android.com/studio">Latest Android Studio</a></p>
<p class="download-target-note">For another host, use a matching source checkout and download the Android libraries as described in the setup guide.</p>
<div class="download-platform">
${package_link("Android package (Windows host)", "android_windows", legacy="android_windows")}
<p><a href="../setup/android-studio/">Android Studio setup / NDK 29</a> · <a href="https://developer.android.com/studio">Latest Android Studio</a></p>
<p class="download-target-note">For another host, use a matching source checkout and download the Android libraries as described in the setup guide.</p>
</div>
</section>

<p>Browse the <a href="https://github.com/openframeworks/openFrameworks/releases/tag/${currentVersion}">${currentVersion} release files</a>, <a href="${NIGHTLY_URL}">nightly builds</a>, or <a href="../download/older/">older releases and beta releases</a>.</p>
Expand Down
49 changes: 49 additions & 0 deletions utils/check_documentation_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
"""Reject loopback URLs in generated API reference links and search entries."""
from html.parser import HTMLParser
from pathlib import Path
import re
import sys
from urllib.parse import urlsplit


def is_loopback(url):
return urlsplit(url.replace("\\/", "/")).hostname in {
"localhost", "127.0.0.1", "0.0.0.0", "::1"
}


class ReferenceLinks(HTMLParser):
def __init__(self):
super().__init__()
self.invalid = []

def handle_starttag(self, tag, attrs):
for name, value in attrs:
if name == "href" and value and is_loopback(value):
self.invalid.append((self.getpos()[0], value))


def main():
root = Path(sys.argv[1] if len(sys.argv) > 1 else "output")
files = [p for p in root.rglob("*.html") if "documentation" in p.relative_to(root).parts]
if not files:
sys.exit("No generated API documentation found in " + str(root))
errors = []
for path in files:
parser = ReferenceLinks()
parser.feed(path.read_text(encoding="utf-8"))
errors.extend("{}:{}: {}".format(path, line, url) for line, url in parser.invalid)
search_files = list(root.rglob("tipuesearch_content.js"))
for path in search_files:
text = path.read_text(encoding="utf-8")
for match in re.finditer(r'"url"\s*:\s*"((?:\\.|[^"\\])*)"', text):
if is_loopback(match.group(1)):
errors.append("{}: {}".format(path, match.group(1)))
if errors:
sys.exit("Loopback documentation URLs:\n" + "\n".join(errors))
print("Checked {} API pages and {} search indexes: no loopback URLs".format(len(files), len(search_files)))


if __name__ == "__main__":
main()
Loading