snapshot
This commit is contained in:
parent
1a35406003
commit
e2316d7ac1
7 changed files with 76 additions and 5 deletions
|
@ -18,6 +18,7 @@ from flask import Flask
|
||||||
from flaskext.markdown import Markdown
|
from flaskext.markdown import Markdown
|
||||||
from markdown.extensions.wikilinks import WikiLinkExtension
|
from markdown.extensions.wikilinks import WikiLinkExtension
|
||||||
from . import util
|
from . import util
|
||||||
|
from flask_cors import CORS
|
||||||
|
|
||||||
def wikilink_to_url(label, base, end):
|
def wikilink_to_url(label, base, end):
|
||||||
label = util.canonical_wikilink(label)
|
label = util.canonical_wikilink(label)
|
||||||
|
@ -30,6 +31,7 @@ def create_app(test_config=None):
|
||||||
app.config.from_mapping(
|
app.config.from_mapping(
|
||||||
SECRET_KEY='dev',
|
SECRET_KEY='dev',
|
||||||
)
|
)
|
||||||
|
CORS(app)
|
||||||
|
|
||||||
if test_config is None:
|
if test_config is None:
|
||||||
# load the instance config, if it exists, when not testing
|
# load the instance config, if it exists, when not testing
|
||||||
|
|
23
app/agora.py
23
app/agora.py
|
@ -13,13 +13,15 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from flask import Blueprint, url_for, render_template, current_app, Response, redirect, request
|
import jsons
|
||||||
|
from flask import Blueprint, url_for, render_template, current_app, Response, redirect, request, jsonify
|
||||||
from markupsafe import escape
|
from markupsafe import escape
|
||||||
from slugify import slugify, SLUG_OK
|
from slugify import slugify, SLUG_OK
|
||||||
from . import config
|
from . import config
|
||||||
from . import db
|
from . import db
|
||||||
from . import forms
|
from . import forms
|
||||||
from . import util
|
from . import util
|
||||||
|
from flask_cors import CORS
|
||||||
bp = Blueprint('agora', __name__)
|
bp = Blueprint('agora', __name__)
|
||||||
G = db.G
|
G = db.G
|
||||||
|
|
||||||
|
@ -149,12 +151,17 @@ def jump():
|
||||||
# Entities
|
# Entities
|
||||||
@bp.route('/wikilink/<node>')
|
@bp.route('/wikilink/<node>')
|
||||||
@bp.route('/node/<node>')
|
@bp.route('/node/<node>')
|
||||||
def node(node):
|
@bp.route('/node/<node>/uprank/<user_list>')
|
||||||
|
def node(node,user_list=""):
|
||||||
|
default_rank = ['agora', 'flancian']
|
||||||
|
rank = user_list.split(",")
|
||||||
|
if len(rank) == 0:
|
||||||
|
rank = default_rank
|
||||||
n = G.node(node)
|
n = G.node(node)
|
||||||
if n.subnodes:
|
if n.subnodes:
|
||||||
# earlier in the list means more highly ranked.
|
# earlier in the list means more highly ranked.
|
||||||
n.subnodes = util.uprank(n.subnodes, users=['agora', 'flancian'])
|
print("rank", rank)
|
||||||
|
n.subnodes = util.uprank(n.subnodes, users=rank)
|
||||||
permutations = []
|
permutations = []
|
||||||
# if it's a 404, include permutations.
|
# if it's a 404, include permutations.
|
||||||
else:
|
else:
|
||||||
|
@ -213,6 +220,10 @@ def garden(garden):
|
||||||
def nodes():
|
def nodes():
|
||||||
return render_template('nodes.html', nodes=G.nodes(include_journals=False))
|
return render_template('nodes.html', nodes=G.nodes(include_journals=False))
|
||||||
|
|
||||||
|
@bp.route('/nodes.json')
|
||||||
|
def nodes_json():
|
||||||
|
return jsonify(jsons.dump(G.nodes(include_journals=False)))
|
||||||
|
|
||||||
@bp.route('/notes') # alias
|
@bp.route('/notes') # alias
|
||||||
@bp.route('/subnodes')
|
@bp.route('/subnodes')
|
||||||
def subnodes():
|
def subnodes():
|
||||||
|
@ -243,3 +254,7 @@ def raw(subnode):
|
||||||
def backlinks(node):
|
def backlinks(node):
|
||||||
# Currently unused.
|
# Currently unused.
|
||||||
return render_template('nodes.html', nodes=db.nodes_by_outlink(node))
|
return render_template('nodes.html', nodes=db.nodes_by_outlink(node))
|
||||||
|
|
||||||
|
@bp.route('/settings')
|
||||||
|
def settings():
|
||||||
|
return render_template('settings.html', header="Settings")
|
||||||
|
|
|
@ -209,3 +209,6 @@ nav { font-family: sans-serif}
|
||||||
This totally doesn't work, at all, and I have no idea why :)
|
This totally doesn't work, at all, and I have no idea why :)
|
||||||
*/
|
*/
|
||||||
.annotator-frame { margin-top: 4.5em }
|
.annotator-frame { margin-top: 4.5em }
|
||||||
|
|
||||||
|
|
||||||
|
.submit {display: block; margin-top: 25px}
|
|
@ -42,3 +42,4 @@ h2 { font-size: 1.2em; }
|
||||||
.wikilink:after {
|
.wikilink:after {
|
||||||
content: "]]"
|
content: "]]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
// Adapted from https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/#toggling-themes
|
// Adapted from https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/#toggling-themes
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
// Hack for settings page
|
||||||
|
try { processSettings({ignore: true}) } catch(e){ console.error(e)}
|
||||||
// Select button
|
// Select button
|
||||||
const btn = document.querySelector(".theme-toggle");
|
const btn = document.querySelector(".theme-toggle");
|
||||||
var theme = document.querySelector("#theme-link");
|
var theme = document.querySelector("#theme-link");
|
||||||
|
@ -40,3 +42,21 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function processSettings(args){
|
||||||
|
args = args || {}
|
||||||
|
let ranking // string for ranking nodes by user, comma separated user list
|
||||||
|
ranking = document.getElementById("settings-ranking").value || ""
|
||||||
|
if (ranking === ""){
|
||||||
|
ranking = localStorage["ranking"] || ""
|
||||||
|
console.log("ranking", ranking)
|
||||||
|
if (ranking !== ""){
|
||||||
|
document.getElementById("settings-ranking").value = ranking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ranking = document.getElementById("settings-ranking").value || ""
|
||||||
|
localStorage["ranking"] = ranking
|
||||||
|
console.log("processing", ranking)
|
||||||
|
if (!args["ignore"]) alert("Settings Saved")
|
||||||
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<h1> Nodes </h1>
|
<h1> Nodes </h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for node in nodes %}
|
{% for node in nodes %}
|
||||||
<a href="{{node.url}}">{{node.wikilink}}</a> ({{node.size()}})<br />
|
<a href="{{node.url}}/uprank/foo,bar">{{node.wikilink}}</a> ({{node.size()}})<br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
30
app/templates/settings.html
Normal file
30
app/templates/settings.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<!--
|
||||||
|
Copyright 2020 Google LLC
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<div >
|
||||||
|
{% if header %}
|
||||||
|
<h1> {{header}} </h1>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
Enter comma separated list of users to rank
|
||||||
|
<input type="text" id="settings-ranking" placeholder="e.g. flancian, vera">
|
||||||
|
<input type="button" value="Save" class="submit" onclick="processSettings()">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue