Browse Source

hacky color separation for riso printing!

technodisobedience
parent
commit
19b677273b
  1. 83
      octomode.py
  2. 2
      static/main.css
  3. 8552
      static/paged.polyfill.js
  4. 9
      templates/base.html
  5. 24
      templates/pagedjs-ck.html
  6. 23
      templates/pagedjs-myk.html
  7. 2
      templates/pagedjs.html
  8. 2
      templates/preview.html
  9. 1
      templates/stylesheet.css

83
octomode.py

@ -5,6 +5,7 @@ from urllib.request import urlopen
from urllib.parse import urlencode, urlparse
import subprocess
from jinja2 import Template
import re
# To sanitize Flask input fields
from markupsafe import Markup, escape
@ -188,6 +189,18 @@ def pdf(name):
url = f"{ app_root }/{name}/pagedjs.html"
return render_template('pdf.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/pdfmyk/')
def pdfmyk(name):
app_root = get_app_root()
url = f"{ app_root }/{name}/pagedjs-myk.html"
return render_template('pdf.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/pdfck/')
def pdfck(name):
app_root = get_app_root()
url = f"{ app_root }/{name}/pagedjs-ck.html"
return render_template('pdf.html', url=url, name=name.strip(), pad_url=APP.config['PAD_URL'])
@APP.route('/<name>/wildcard-template/')
def wildcardtemplate(name):
url = f"{ APP.config['PAD_URL'] }/{ name }.wildcard-template.html"
@ -212,9 +225,8 @@ def podcast(name):
@APP.route('/<name>/stylesheet.css')
def css(name):
css = get_pad_content(name, '.css')
css = get_pad_content(name, ext='.css')
# Insert CSS sanitizer here.
return css, 200, {'Content-Type': 'text/css; charset=utf-8'}
# only used for the pandoc command using the subprocess
@ -252,25 +264,78 @@ def preview(name):
def pagedjs(name):
# TO GENERATE THE PAGED.JS PAGE
md_pad_content = get_pad_content(name, ext='.md')
### HACKSS START HERE
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.colorz})", r"\1.myk-ck/\2.jpg\3", md_pad_content)
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.mono})", r"\1.ck/\2-col.jpg\3", md_pad_content)
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.othermono})", r"\1.myk/\2-col.jpg\3", md_pad_content)
### HACKSS END HERE
html = md_to_html(md_pad_content, name)
metadata = get_md_metadata(md_pad_content)
lang = metadata['language'][0]
title = metadata['title'][0]
return render_template('pagedjs.html', name=name.strip(), pad_content=html, lang=lang, title=title)
@APP.route('/<name>/pagedjs-myk.html')
def pagedjsmyk(name):
# TO GENERATE THE PAGED.JS PAGE
md_pad_content = get_pad_content(name, ext='.md')
### HACKSS START HERE
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.colorz})", r"\1.myk/\2.jpg\3", md_pad_content)
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.othermono})", r"\1.myk/\2.jpg\3", md_pad_content)
### HACKSS END HERE
html = md_to_html(md_pad_content, name)
metadata = get_md_metadata(md_pad_content)
lang = metadata['language'][0]
title = metadata['title'][0]
return render_template('pagedjs-myk.html', name=name.strip(), pad_content=html, lang=lang, title=title)
@APP.route('/<name>/pagedjs-ck.html')
def pagedjsck(name):
# TO GENERATE THE PAGED.JS PAGE
md_pad_content = get_pad_content(name, ext='.md')
### HACKSS START HERE
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.colorz})", r"\1.ck/\2.jpg\3", md_pad_content)
md_pad_content=re.sub(r"(!.+/publication/images/)(.+)(\){.mono})", r"\1.ck/\2.jpg\3", md_pad_content)
### HACKSS END HERE
html = md_to_html(md_pad_content, name)
metadata = get_md_metadata(md_pad_content)
lang = metadata['language'][0]
title = metadata['title'][0]
return render_template('pagedjs-ck.html', name=name.strip(), pad_content=html, lang=lang, title=title)
@APP.route('/<name>/wildcard.html')
def wildcardpage(name):
md_pad_content = get_pad_content(name, ext='.md')
wildcard_template_pad_content = get_pad_content(name, ext='.wildcard-template.html')
audio = []
pdf = []
images = []
allall = []
for line in md_pad_content.splitlines():
if ".mp3" in line:
audio.append(line)
elif ".ogg" in line:
audio.append(line)
return render_template_string(wildcard_template_pad_content, name=name.strip(), audio=audio)
slines=re.split("\s|\"|\(|\)|>|<",line)
for sline in slines:
if "http" in sline and sline not in allall:
if ".mp3" in sline:
audio.append(sline)
allall.append(sline)
elif ".ogg" in sline:
audio.append(sline)
allall.append(sline)
elif ".pdf" in sline:
pdf.append(sline)
allall.append(sline)
elif ".jpg" in sline:
images.append(sline)
allall.append(sline)
return render_template_string(wildcard_template_pad_content, name=name.strip(), allall=allall, pdf=pdf, images=images, audio=audio)
@APP.route('/<name>/podcast.rss')
def rss(name):

2
static/main.css

@ -6,7 +6,7 @@
body{
min-width: 900px;
background-color: darkkhaki;
background-color: #8798d6;
}
/* GENERAL RULES */

8552
static/paged.polyfill.js

File diff suppressed because it is too large

9
templates/base.html

@ -41,15 +41,18 @@ window.addEventListener('load', function () {
<a href="{{ url_for('pdf', name=name) }}"><button>pdf</button></a>
<a class="link" href="{{ url_for('pagedjs', name=name) }}" target="_blank">🔗</a>
<a href="{{ url_for('pdfck', name=name) }}"><button>pdf-ck</button></a>
<a class="link" href="{{ url_for('pagedjsck', name=name) }}" target="_blank">🔗</a>
<a href="{{ url_for('pdfmyk', name=name) }}"><button>pdf-myk</button></a>
<a class="link" href="{{ url_for('pagedjsmyk', name=name) }}" target="_blank">🔗</a>
<a href="{{ url_for('wildcardtemplate', name=name) }}"><button>* template</button></a>
<a class="link" href="{{ pad_url }}/{{ name }}.wildcard-template.html" target="_blank">🔗</a>
<a href="{{ url_for('wildcard', name=name) }}"><button>*</button></a>
<a class="link" href="{{ url_for('wildcardpage', name=name) }}" target="_blank"> 🔗</a>
<a href="{{ url_for('podcast', name=name) }}"><button>podcast</button></a>
<a class="link" href="{{ url_for('rss', name=name) }}" target="_blank"> 🔗</a>
</div>`;
document.body.insertBefore(nav, document.body.firstChild);

24
templates/pagedjs-ck.html

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="{{ url_for('static', filename='paged.polyfill.js') }}" type="text/javascript"></script>
<link href="{{ url_for('static', filename='pagedjs.css') }}" rel="stylesheet" type="text/css" media="screen">
<link href="/octomode/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
<title>{{ title }}</title>
<style>
:root{
--purple:#000000 !important;
--orange:transparent !important;
}
@page spreadLayout{
background:white !important;
}
</style>
</head>
<body class="only-ck">
{{ pad_content }}
</body>
</html>

23
templates/pagedjs-myk.html

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="{{ url_for('static', filename='paged.polyfill.js') }}" type="text/javascript"></script>
<link href="{{ url_for('static', filename='pagedjs.css') }}" rel="stylesheet" type="text/css" media="screen">
<link href="/octomode/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
<title>{{ title }}</title>
<style>
:root{
--orange: #000000 !important;
--purple: transparent !important;
}
@page cover{
background-color:white !important;
}
</style>
</head>
<body class='only-myk'>
{{ pad_content }}
</body>
</html>

2
templates/pagedjs.html

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="{{ url_for('static', filename='paged.polyfill.js') }}" type="text/javascript"></script>
<link href="{{ url_for('static', filename='pagedjs.css') }}" rel="stylesheet" type="text/css" media="screen">
<link href="/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
<link href="/octomode/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="print">
<title>{{ title }}</title>
</head>
<body>

2
templates/preview.html

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="screen">
<link href="/octomode/{{ name }}/stylesheet.css" rel="stylesheet" type="text/css" media="screen">
<title>{{ title }}</title>
</head>
<body>

1
templates/stylesheet.css

@ -0,0 +1 @@
{{ content }}
Loading…
Cancel
Save