diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-03-21 12:49:50 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-03-21 12:49:50 -0700 |
commit | cbe805902078195c374560c9000ac39b46975ed0 (patch) | |
tree | d21629167cb1dfec138b921ea52520b1c9908561 | |
parent | 87c317c518f0bec49b7f8189dc6f1bcefc8d6ff0 (diff) | |
download | fatcat-cbe805902078195c374560c9000ac39b46975ed0.tar.gz fatcat-cbe805902078195c374560c9000ac39b46975ed0.zip |
webface templates
-rw-r--r-- | notes/webface_notes.txt (renamed from webface/notes.txt) | 0 | ||||
-rw-r--r-- | webface/static/robots.txt | 1 | ||||
-rw-r--r-- | webface/templates/base.html | 70 | ||||
-rw-r--r-- | webface/templates/home.html | 32 | ||||
-rw-r--r-- | webface/templates/work_add.html (renamed from webface/index.html) | 59 | ||||
-rw-r--r-- | webface/templates/work_view.html | 37 | ||||
-rwxr-xr-x | webface/webface.py | 87 |
7 files changed, 233 insertions, 53 deletions
diff --git a/webface/notes.txt b/notes/webface_notes.txt index 8ed47d0b..8ed47d0b 100644 --- a/webface/notes.txt +++ b/notes/webface_notes.txt diff --git a/webface/static/robots.txt b/webface/static/robots.txt new file mode 100644 index 00000000..a168f11b --- /dev/null +++ b/webface/static/robots.txt @@ -0,0 +1 @@ +# Hello friends! diff --git a/webface/templates/base.html b/webface/templates/base.html new file mode 100644 index 00000000..4e9dcd4b --- /dev/null +++ b/webface/templates/base.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html lang="en" style="position: relative; min-height: 100%; height: auto;"> +<head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width"> + + <title>{% block title %}fatcat!{% endblock %}</title> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.13/dist/semantic.min.css"> + <script + src="https://code.jquery.com/jquery-3.1.1.min.js" + integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" + crossorigin="anonymous"></script> + <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.13/dist/semantic.min.js"></script> + +</head> +<body style="margin-bottom: 100px; height: auto;"> + +<header class="ui fixed inverted menu"> + <div class="ui container"> + <a href="/" class="header item"> + <!-- <img class="logo" src="assets/images/logo.png"> --> + fatcat! + </a> + <a href="/about" class="item">About</a> + <a href="#" class="item">Guide</a> + <div class="right menu"> + <div class="item"> + <div class="ui transparent inverted icon input"> + <i class="search icon"></i> + <input type="text" placeholder="Search..."> + </div> + </div> + <div class="ui simple dropdown item"> + acidburn <i class="dropdown icon"></i> + <div class="menu"> + <a class="item" href="#">Open Submissions</a> + <a class="item" href="#">Edit History</a> + <div class="divider"></div> + <a class="item" href="/account">Account</a> + <a class="item" href="/logout">Logout</a> + </div> + </div> + + </div> + </div> +</header> + +<main class="ui main text container" style="margin-top: 4em; margin-bottom: 2em;"> +{% block body %}Nothing to see here.{% endblock %} +</main> + + +<footer class="ui inverted vertical footer segment" style="margin-top: 2em; padding-top: 2em; padding-bottom:2em; position: absolute; bottom: 0px; width: 100%;"> + <div class="ui center aligned container"> + <div class="ui horizontal inverted small divided link list"> + <span class="item">fatcat!</span> + <a class="item" href="/about">About</a> + <a class="item" href="/sources">Sources</a> + <a class="item" href="#">Status</a> + <a class="item" href="#">Datasets</a> + <a class="item" href="https://git.bnewbold.net/fatcat/">Source Code</a> + </div> + </div> +</footer> + +{% block postscript %}{% endblock %} + +</body> +</html> diff --git a/webface/templates/home.html b/webface/templates/home.html new file mode 100644 index 00000000..d9cc34a2 --- /dev/null +++ b/webface/templates/home.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% block body %} + +<h1>Salutations!</h1> + +Just mockups for now... + +<ul> + <li><b>Work:</b> + <a href="/work/create">Create</a>, + <a href="/work/random">Random</a> + <li><b><strike>Release:</strike></b> + <a href="/release/create">Create</a>, + <a href="/release/random">Random</a> + <li><b><strike>File:</strike></b> + <a href="/file/create">Create</a>, + <a href="/file/random">Random</a> + <li><b><strike>Contributor:</strike></b> + <a href="/contrib/create">Create</a>, + <a href="/contrib/random">Random</a> + <li><b><strike>Container:</strike></b> + <a href="/container/create">Create</a>, + <a href="/container/random">Random</a> + <li><b><strike>Publisher:</strike></b> + <a href="/publisher/create">Create</a>, + <a href="/publisher/random">Random</a> + <li>Edit groups... + <li>Changelog... + <li>Login/Signup... +</ul> + +{% endblock %} diff --git a/webface/index.html b/webface/templates/work_add.html index 6e269e38..ac8a8169 100644 --- a/webface/index.html +++ b/webface/templates/work_add.html @@ -1,51 +1,5 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width"> - - <title> </title> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.13/dist/semantic.min.css"> - <script - src="https://code.jquery.com/jquery-3.1.1.min.js" - integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" - crossorigin="anonymous"></script> - <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.2.13/dist/semantic.min.js"></script> - -</head> -<body> - -<div class="ui fixed inverted menu"> - <div class="ui container"> - <a href="#" class="header item"> - <!-- <img class="logo" src="assets/images/logo.png"> --> - Project Name - </a> - <a href="#" class="item">Home</a> - <div class="ui simple dropdown item"> - Dropdown <i class="dropdown icon"></i> - <div class="menu"> - <a class="item" href="#">Link Item</a> - <a class="item" href="#">Link Item</a> - <div class="divider"></div> - <div class="header">Header Item</div> - <div class="item"> - <i class="dropdown icon"></i> - Sub Menu - <div class="menu"> - <a class="item" href="#">Link Item</a> - <a class="item" href="#">Link Item</a> - </div> - </div> - <a class="item" href="#">Link Item</a> - </div> - </div> - </div> -</div> - -<div class="ui main text container"> - +{% extends "base.html" %} +{% block body %} <div class="ui segment"> <h1 class="ui header">Adding a New Thing</h1> @@ -149,10 +103,11 @@ </form> </div> -</div> +{% endblock %} -<!-- Form validation code --> +{% block postscript %} <script> +<!-- Form validation code --> $(document).ready(function() { $('#add_work_form') @@ -257,6 +212,4 @@ $(document).ready(function() { }); </script> - -</body> -</html> +{% endblock %} diff --git a/webface/templates/work_view.html b/webface/templates/work_view.html new file mode 100644 index 00000000..8c5e955d --- /dev/null +++ b/webface/templates/work_view.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} +{% block body %} + +<h1>{{ work.title }}</h1> + +<p>Work type: {{ work.type }} +<p><a href="/work/{{ work.id }}/history">History</a> +<p>Contributors: +{% for c in work.contributors %} {{ c.name }}; {% endfor %} + +{% if primary %} +<h2>Primary Release/Edition</h2> +<p>Title: {{ primary.title }} +<p>Date: {{ primary.date }} + +{% if primary.container %} +<p>Container: <a href="/container/{{ primary.container.id }}">{{ primary.container.title }}</a> +{% endif %} + +{% if primary.doi %} +<p>DOI: <a href="https://dx.doi.org/{{ primary.doi }}">{{ primary.doi }}</a> +{% endif %} + +{% else %} +<p>No primary release +{% endif %} + +{% if releases %} +<ul> +{% for r in releases %} + <ul><a href="/release/{{ r.id }}">{{ r.title }}</a> ({{ y.date }} - {{ y.release_type }}) +{% endfor %} +</ul> +{% else %} +{% endif %} + +{% endblock %} diff --git a/webface/webface.py b/webface/webface.py new file mode 100755 index 00000000..33833e25 --- /dev/null +++ b/webface/webface.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 + +import os +import argparse +import requests +from flask import Flask, render_template, send_from_directory, request, \ + url_for, abort, g, redirect, jsonify + +app = Flask(__name__) +app.config.from_object(__name__) + + +### Views ################################################################### + +@app.route('/health', methods=['GET']) +def health(): + return jsonify({'ok': True}) + +@app.route('/work/create', methods=['GET']) +def work_create(): + return render_template('work_add.html') + +@app.route('/work/random', methods=['GET']) +def work_random(): + work = { + "title": "Structure and Interpretation", + "work_type": "book", + "date": None, + "contributors": [ + {"name": "Alyssa P. Hacker"}, + ], + "primary": { + "title": "Structure and Interpretation", + "release_type": "online", + "date": "2000-01-01", + "doi": "10.491/599.sdo14", + }, + "releases": [ + ] + } + return render_template('work_view.html', work=work, primary=work['primary']) + +@app.route('/work/<work_id>/random', methods=['GET']) +def work_view(work_id): + return render_template('work_view.html') + + +### Static Routes ########################################################### + +@app.route('/', methods=['GET']) +def homepage(): + return render_template('home.html') + +@app.route('/about', methods=['GET']) +def aboutpage(): + return render_template('about.html') + +@app.route('/robots.txt', methods=['GET']) +def robots(): + return send_from_directory(os.path.join(app.root_path, 'static'), + 'robots.txt', + mimetype='text/plain') + + +### Entry Point ############################################################# + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--debug', + action='store_true', + help="enable debugging interface") + parser.add_argument('--host', + default="127.0.0.1", + help="listen on this host/IP") + parser.add_argument('--port', + type=int, + default=5050, + help="listen on this port") + parser.add_argument('--backend-api', + default="localhost:6060", + help="backend API to connect to") + args = parser.parse_args() + + app.run(debug=args.debug, host=args.host, port=args.port) + +if __name__ == '__main__': + main() |