Compare commits

..

No commits in common. "8dda38ef5286a0220d7b10339f9753a323e3eaeb" and "6bb188f970a1d2a51a0f9f7e0a9ca9a7bbab7772" have entirely different histories.

4 changed files with 2 additions and 197 deletions

View File

@ -126,7 +126,6 @@ class DocumentTab:
A division of tags within a document. A division of tags within a document.
""" """
def __init__(self, name: str, tags: List[DocumentTag], options: TabOptions) -> None: def __init__(self, name: str, tags: List[DocumentTag], options: TabOptions) -> None:
self.name = name
self.tags: List[DocumentTag] = tags self.tags: List[DocumentTag] = tags
self.options: TabOptions = options self.options: TabOptions = options

View File

@ -1,40 +1,3 @@
"""
Logic for serving a collection of documents through a web frontend.
"""
import argparse
import os
from flask import Flask, redirect, url_for, current_app, render_template
from redstring.parser import load
CONFIG_ENVVAR = 'REDSTRING_CONFIG'
app = Flask(__name__)
@app.route('/')
def root():
return redirect(url_for('index'))
@app.route('/index/')
def index():
with open('scratch/test.json') as f:
document = load(f)
return render_template('doc.jinja', document=document)
def main(): def main():
parser = argparse.ArgumentParser(description="Run the redstring server.") print("Hello, world!")
parser.add_argument("--config", help="Config file path.") print(__name__)
args = parser.parse_args()
config_path = args.config or os.environ.get(CONFIG_ENVVAR) or '/etc/redstring.conf'
# TODO
document_folder = args.config # TODO
app.config['root'] = document_folder
app.run(debug=True, port=5000)

View File

@ -1,104 +0,0 @@
<html>
<head>
<meta charset="UTF-8">
<title>{{ page_title }}</title>
<meta property="og:title" content="{{ page_title }}" />
<meta property="og:type" content="website" />
{% if page_summary -%}
<meta property="og:description" content="{{ page_summary }}" />
{% endif -%}
<link rel="icon" href="data:;base64,=">
<style>
/* Page structure */
body {
background-color: #000000;
margin: 0px;
}
div#wrapper {
background-color: #303030;
color: #ffffff;
max-width: 700px;
margin-left: auto;
margin-right: auto;
padding-top: 10px;
}
/* Tabs setup */
div.tab {
display: inline-block;
padding: 5px;
background-color: #303030;
border-style: solid;
border-color: #808080;
border-width: 2px 2px 0 2px;
border-radius: 10px 10px 0px 0px;
margin: 0 0 0 4px;
font-family: monospace;
font-weight: bold;
color: #808080;
cursor: pointer;
user-select: none
}
div.tab-selected {
background-color: #303030;
border-color: #b0b0b0;
color: #b0b0b0;
position: relative;
top: 2px;
}
div.tab-right {
float: right;
margin: 0 4px 0 0;
}
div.tab-content {
width: 100%;
border-top: 2px solid #b0b0b0;
display: none;
}
div.tab-selected-content {
display: block;
-padding: 5px;
}
/* Content tables */
table.content-table {
width: 100%;
color: #ffffff;
font-family: serif;
white-space: pre-wrap;
border-collapse: collapse;
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
word-break: break-word;
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
table.content-table tr {
border-bottom: 1px solid #808080;
}
table.content-table td {
padding: 5px;
}
table.content-table td:nth-child(1) {
width: 150px;
font-weight: bold;
vertical-align:top
}
table.content-table tr.hide-tag-name td:nth-child(1) {
display: none;
}
table.content-table td:nth-child(2) {
white-space: pre-wrap;
}
</style>
{% block page_scripts %}{% endblock %}
</head>
<body>
<div id="wrapper">
{% block page_content %}{% endblock %}
</div>
</body>
</html>

View File

@ -1,53 +0,0 @@
{% extends 'base.jinja' %}
{% set page_title = 'tmp' -%}
{% set page_summary = 'tmpp' %}
{% block page_scripts %}
<script>
function selectTab(name) {
let tab = document.getElementById(name);
if (tab)
{
// Unselect all tabs and content
Array.from(document.getElementsByClassName("tab"))
.forEach(e => e.classList.remove("tab-selected"));
Array.from(document.getElementsByClassName("tab-content"))
.forEach(e => e.classList.remove("tab-selected-content"));
// Select the new tab and content
tab.classList.add("tab-selected");
let content = document.getElementById(name + "-content");
content.classList.add("tab-selected-content");
}
}
window.onload = function () {
// Respect fragment as a tab selector shortcut
if (window.location.hash) {
selectTab(window.location.hash.substring(1));
}
}
</script>
{% endblock page_scripts %}
{% macro make_tab(tab, selected) -%}
<div id="{{ tab.name }}" class="tab{% if selected %} tab-selected{% endif %}" onclick="javascript:selectTab('{{ tab.name }}')">{{ tab.name }}</div>
{%- endmacro %}
{% macro make_tab_content(tab, selected) %}
<div id="{{ tab.name }}-content" class="tab-content{% if selected %} tab-selected-content{% endif %}">
<table id="{{ tab.name }}-content-table" class="content-table">
{% for tag in tab %}
<tr {% if tab.options.hide_names %}class="hide-tag-name"{% endif %}>
<td>{{ tag.name }}</td>
<td>{{ tag.value }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endmacro %}
{% block page_content %}
{% for tab in document %}{{ make_tab(tab, loop.first) }}{% endfor %}<a href="/index/"><div id="index" class="tab tab-right">index</div></a>
{% for tab in document %}{{ make_tab_content(tab, loop.first) }}{% endfor %}
{% endblock page_content %}