First commit

This commit is contained in:
thematdev 2021-08-26 21:51:26 +03:00
commit 85bfdd233e
15 changed files with 812 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.env
**/__pycache__/
.idea/

11
Pipfile Normal file
View File

@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.9"

20
Pipfile.lock generated Normal file
View File

@ -0,0 +1,20 @@
{
"_meta": {
"hash": {
"sha256": "a36a5392bb1e8bbc06bfaa0761e52593cf2d83b486696bf54667ba8da616c839"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.9"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {},
"develop": {}
}

1
README.md Normal file
View File

@ -0,0 +1 @@
# Wiki pages

43
app/__init__.py Normal file
View File

@ -0,0 +1,43 @@
from dotenv import load_dotenv
from flask import Flask, url_for, render_template
import os
import json
from app.config import PANDOC_LINK, PANDOC_PATH
import subprocess
load_dotenv()
app = Flask(__name__)
@app.context_processor
def override_url_for():
return dict(url_for=dated_url_for)
#TODO: make instead of datetime hash of commit
def dated_url_for(endpoint, **values):
if endpoint == 'static':
filename = values.get('filename', None)
if filename:
file_path = os.path.join(app.root_path, endpoint, filename)
values['q'] = int(os.stat(file_path).st_mtime)
return url_for(endpoint, **values)
@app.route(f'/{PANDOC_LINK}/<page>')
def get_pandoc_page(page):
with open(f'{PANDOC_PATH}/{page}/config.json') as f:
data = json.loads(f.read())
filename = f'{PANDOC_PATH}/{page}/main.md'
inserted = subprocess.Popen(f'pandoc {filename} -t html --mathjax', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
template = data['template']
return render_template(template, markdown=inserted)
@app.route('/')
def index():
return render_template('index.html')

2
app/config.py Normal file
View File

@ -0,0 +1,2 @@
PANDOC_LINK = 'page'
PANDOC_PATH = '/home/thematdev/pandoc_pages'

547
app/static/css/pandoc.css Normal file
View File

@ -0,0 +1,547 @@
/*
* Forked from https://gist.github.com/killercup/5917178
*/
@font-face {
font-family: 'CMU';
src: url('/static/fonts/cmu.woff2');
}
@font-face {
font-family: 'Lora';
src: url('/static/fonts/lora.ttf');
}
@font-face {
font-family: 'Inconsolata';
src: url('/static/fonts/inconsolata.woff2');
}
@font-face {
font-family: 'Garamond';
src: url('/static/fonts/garamond.woff2');
}
@font-face {
font-family: "Open Sans";
src: url('/static/fonts/opensans.woff2');
}
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
a {
white-space: pre; /* for some weird reason this affects pre blocks */
}
body {
/* color: #444; */
font-family: "Times New Roman", Times, "Tinos", serif;
font-size: 16px;
line-height: 1.7;
padding: 8px;
margin: auto;
width: 750px;
background: #fefefe;
text-align: justify;
padding-bottom: 25px;
}
.credits {
font-size: 14px;
margin: 25px 10px -40px 15px;
padding: 16px 50px 0 50px;
/* text-align: left; */
border-top: 1px solid #666;
color: black;
}
.credits table {
border: none;
margin-left: 46px;
margin-bottom: 10px;
}
.credits table td{
border: none;
padding: 0;
padding-left: 1.5em;
}
#header {
height: 55px;
margin-top: -8px;
margin-bottom: 20px;
border-bottom: 1px solid #666;
}
#links {
display: inline-block;
text-align: right;
font-size: 16px;
float: right;
margin-top: 17px;
margin-right: 12px;
}
#links a {
margin-left: 20px;
}
#header a:hover {
color: #0645ad!important;
}
#header a {
color: #111 !important;
display: inline-block;
}
#logo {
margin-top: 10px;
font-size: 22px;
height: 0;
font-family: 'Garamond', serif;
}
.contents {
position: inline-block;
float: left;
position: relative;
left: 12px;
width: 285px;
text-align: left;
}
.contents ul {
padding-left: 22px;
margin-top: 10px;
list-style-type: none;
}
.contents li {
font-size: 8px;
color: lightgrey;
font-family: 'Open Sans', sans;
height: 30px;
line-height: 8px;
list-style-type: none;
white-space: pre-line;
}
.contents li:hover {
color: black;
}
.contents li:first-letter {
font-size: 13px;
height: 0;
}
.contents a {
font-family: "Times New Roman", Times, "Tinos", serif;
font-size: 16px;
line-height: 1em;
display: inline-block;
width: 252px;
}
.contents a:first-letter {
font-size: 16px; /* the only way to fix */
}
.contents a:after {
content: "\A";
white-space: pre;
}
.contents li:before {
content: '•';
display: inline-block;
position: absolute;
left: 11px;
margin-top: 5px;
color: black !important;
font-size: 18px;
}
a {
color: #0645ad;
text-decoration: none;
}
a:visited {
color: #0b0080;
}
a:hover {
color: #06e;
}
a:active {
color: #faa700;
}
a:focus {
outline: thin dotted;
}
p {
margin: 0.5em 0;
}
img {
max-width: 100%;
}
.title {
display: none;
}
h1 {
text-align: center;
margin-bottom: 0.8em !important;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Garamond', serif;
color: #111;
line-height: 125%;
margin-top: 1em;
margin-bottom: 0em;
font-weight: normal;
}
h2, h3 {
padding-bottom: 5px;
border-bottom: 1px solid #eaecef;
}
.contents h2, .contents h3 {
padding-bottom: 0;
border-bottom: none;
margin-top: 5px;
}
h4, h5, h6 {
font-weight: bold;
}
h1 {
font-size: 2.5em;
margin-top: 0.8em;
}
h2 {
font-size: 2em;
}
h3 {
font-size: 1.5em;
}
h4 {
font-size: 1.2em;
}
h5 {
font-size: 1em;
}
h6 {
font-size: 0.9em;
}
blockquote {
color: #666666;
margin: 0;
padding-left: 1em;
border-left: 0.5em #EEE solid;
}
hr {
display: block;
width: 100%;
height: 0px;
border: 0;
margin: 0;
padding: 0;
clear: both;
}
pre, code, kbd, samp {
color: #000;
font-family: 'Inconsolata', monospace;
}
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
b, strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
ins {
background: #ff9;
color: #000;
text-decoration: none;
}
mark {
background: #ff0;
color: #000;
font-style: italic;
font-weight: bold;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
ul, ol {
margin: 1em 0;
padding: 0 0 0 2em;
}
li p:last-child {
margin-bottom: 0;
}
li ul {
padding-left: 18px;
padding-top: 1px;
}
ul ul, ol ol {
margin: .3em 0;
}
dl {
margin-bottom: 1em;
}
dt {
font-weight: bold;
margin-bottom: .8em;
}
dd {
margin: 0 0 .8em 2em;
}
dd:last-child {
margin-bottom: 0;
}
img {
border: 0;
-ms-interpolation-mode: bicubic;
vertical-align: middle;
}
figure {
display: block;
text-align: center;
margin: 1em 0;
}
img {
border: none;
margin: auto;
display: block;
max-width: 85%;
max-height: 320px;
}
figcaption {
font-size: 0.8em;
font-style: italic;
margin: 0 0 .8em;
}
table {
margin-bottom: 2em;
border-bottom: 1px solid #ddd;
border-right: 1px solid #ddd;
border-spacing: 0;
border-collapse: collapse;
}
table th {
padding: .2em 1em;
background-color: #eee;
border-top: 1px solid #ddd;
border-left: 1px solid #ddd;
}
table td {
padding: .2em 1em;
border-top: 1px solid #ddd;
border-left: 1px solid #ddd;
vertical-align: top;
}
.author {
display: block;
width: 100%;
text-align: right;
margin-top: -30px;
margin-bottom: 40px;
padding-right: 20px;
/* position: absolute; */
color: #444;
font-size: 0.8em;
}
code:not([class]) {
border: 1px solid #ddd !important;
background-color: #f8f8f8 !important;
border-radius: 3px !important;
padding-left: 2px !important;
padding-right: 2px !important;
font-size: 0.85em;
}
pre {
border: 1px solid #ddd !important;
background-color: #f8f8f8 !important;
border-radius: 3px !important;
padding: 2px !important;
padding-left: 8px !important;
font-size: 0.9em;
}
@media print {
body {
font-size: 12pt;
width: 190mm;
margin: 0;
/*margin-left 10mm;*/
}
@page { margin: 15mm; }
#header {
display: none;
}
pre, ul, ol {
page-break-inside: avoid;
}
h1::after, h2::after, h3::after {
/* page-break-after: avoid; */
content: "";
display: block;
height: 100px;
margin-bottom: -100px;
}
/*
h1::before, h2::before, h3::before {
content: "";
display: block;
height: 100px;
margin-top: 100px;
}
*/
a, a:visited {
text-decoration: underline;
}
/*
abbr[title]:after {
content: " (" attr(title) ")";
}
*/
p, h2, h3 {
orphans: 3;
widows: 3;
}
}
/*
a[href^='http://sereja.me']:before {
content: url('http://sereja.me/favicon.ico');
margin-right: 4px;
}
*/
a[href^='http://e-maxx.ru']:before {
content: "";
display: inline-block;
position: relative;
top: 4px;
width: 20px;
height: 20px;
background: url('http://e-maxx.ru/favicon.ico') no-repeat;
background-size: 18px;
}
/*
a[href^='https://algorithmica.org']:before {
content: "";
display: inline-block;
position: relative;
top: 4px;
width: 20px;
height: 20px;
background: url('https://algorithmica.org/favicon.ico') no-repeat;
background-size: 18px;
}
*/
/* https://habrahabr.ru/favicon.ico */
a[href^='https://neerc.ifmo.ru']:before {
content: url('https://neerc.ifmo.ru/favicon.ico');
margin-right: 4px;
position: relative;
top: 4px;
}
a[href^='https://www.youtube.com']:before {
content: url('https://www.youtube.com/favicon.ico');
margin-right: 4px;
}
a[href^='https://codeforces.com']:before {
content: url('http://codeforces.com/favicon.ico');
margin-right: 4px;
}
a[href^='https://www.topcoder.com/']:before {
content: url('https://s3.amazonaws.com/app.topcoder.com/favicon.ico');
margin-right: 4px;
}
a[href=''] {
color: black;
cursor: default;
}

153
app/static/css/prism.css Normal file
View File

@ -0,0 +1,153 @@
/* PrismJS 1.24.1
https://prismjs.com/download.html#themes=prism-solarizedlight&languages=markup+css+clike+javascript+c+cpp */
/*
Solarized Color Schemes originally by Ethan Schoonover
http://ethanschoonover.com/solarized
Ported for PrismJS by Hector Matos
Website: https://krakendev.io
Twitter Handle: https://twitter.com/allonsykraken)
*/
/*
SOLARIZED HEX
--------- -------
base03 #002b36
base02 #073642
base01 #586e75
base00 #657b83
base0 #839496
base1 #93a1a1
base2 #eee8d5
base3 #fdf6e3
yellow #b58900
orange #cb4b16
red #dc322f
magenta #d33682
violet #6c71c4
blue #268bd2
cyan #2aa198
green #859900
*/
code[class*="language-"],
pre[class*="language-"] {
color: #657b83; /* base00 */
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
background: #073642; /* base02 */
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
background: #073642; /* base02 */
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background-color: #fdf6e3; /* base3 */
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #93a1a1; /* base1 */
}
.token.punctuation {
color: #586e75; /* base01 */
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #268bd2; /* blue */
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.url,
.token.inserted {
color: #2aa198; /* cyan */
}
.token.entity {
color: #657b83; /* base00 */
background: #eee8d5; /* base2 */
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #859900; /* green */
}
.token.function,
.token.class-name {
color: #b58900; /* yellow */
}
.token.regex,
.token.important,
.token.variable {
color: #cb4b16; /* orange */
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}

BIN
app/static/fonts/cmu.woff2 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

9
app/static/js/prism.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<link rel="stylesheet" href="{{ url_for('static', filename='css/pandoc.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/prism.css') }}">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body>
{{markdown|safe}}
<script>
var divs = document.getElementsByTagName("code");
for (var i = 0; i < divs.length; i++) {
divs[i].classList.add("language-cpp");
}
</script>
<script src="{{ url_for('static', filename='js/prism.js') }}"></script>
</body>
</html>

1
app/templates/index.html Normal file
View File

@ -0,0 +1 @@
Wiki index page