aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMart Raudsepp <leio@gentoo.org>2016-11-23 01:54:03 +0200
committerMart Raudsepp <leio@gentoo.org>2016-11-23 01:58:04 +0200
commit971600fca7c3fd6599d4133d10e32d27d3cfc6e5 (patch)
tree8643b701fa5d074797f30fffcaa413f5bcc82cf9 /frontend
parentAdd parsed project members to the result dict (diff)
downloadgrumpy-971600fca7c3fd6599d4133d10e32d27d3cfc6e5.tar.gz
grumpy-971600fca7c3fd6599d4133d10e32d27d3cfc6e5.tar.bz2
grumpy-971600fca7c3fd6599d4133d10e32d27d3cfc6e5.zip
Make the dummy initial web frontend pretty
Now uses extra Flask-Classy dependency for nicer routing and organization. Stylesheet is Gentoo Tyrian loaded from standard CDN location. Reorganizes some of frontend to frontend module, which necessitates telling Flask it's "frontend", not "backend" (for templates to work without passing custom paths). If reorganization goes this route and completes, all the flask parts should end up in frontend module, making this hack obsolete. Though backend might want to use Flask-Sqlalchemy too, so needing the Flask app object, but not sure yet.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/__init__.py5
-rw-r--r--frontend/grumpy.py12
-rw-r--r--frontend/templates/base.html62
-rw-r--r--frontend/templates/index.html22
4 files changed, 101 insertions, 0 deletions
diff --git a/frontend/__init__.py b/frontend/__init__.py
new file mode 100644
index 0000000..79078b8
--- /dev/null
+++ b/frontend/__init__.py
@@ -0,0 +1,5 @@
+from .grumpy import GrumpyView
+
+__all__ = [
+ "GrumpyView",
+] \ No newline at end of file
diff --git a/frontend/grumpy.py b/frontend/grumpy.py
new file mode 100644
index 0000000..007748e
--- /dev/null
+++ b/frontend/grumpy.py
@@ -0,0 +1,12 @@
+from flask import render_template, request
+from flask_classy import FlaskView
+
+from backend.lib import models
+
+
+class GrumpyView(FlaskView):
+ route_base='/'
+
+ def index(self):
+ categories = models.Category.query.all()
+ return render_template("index.html", categories=categories)
diff --git a/frontend/templates/base.html b/frontend/templates/base.html
new file mode 100644
index 0000000..62288f5
--- /dev/null
+++ b/frontend/templates/base.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>{% block title %}Grumpy{% endblock %}</title>
+ <link rel="stylesheet" href="https://assets.gentoo.org/tyrian/bootstrap.min.css"/>
+ <link rel="stylesheet" href="https://assets.gentoo.org/tyrian/tyrian.min.css"/>
+ <meta name="theme-color" content="#54487a"/>
+</head>
+<body>
+<header>
+ <div class="site-title">
+ <div class="container">
+ <div class="row">
+ <div class="site-title-buttons">
+ <div class="btn-group btn-group-sm">
+ <a href="https://get.gentoo.org" role="button" class="btn get-gentoo"><span class="fa fa-fw fa-download"></span><strong>Get Gentoo!</strong></a>
+ {# TODO: Add the standard "gentoo.org sites" snippet (via jinja macro?); is there some API to use to get this list instead of hardcoding? #}
+ </div>
+ </div>
+ <div class="logo">
+ <a href="/" title="Back to the homepage" class="site-logo">
+ <object data="https://assets.gentoo.org/tyrian/site-logo.svg" type="image/svg+xml">
+ <img src="https://assets.gentoo.org/tyrian/site-logo.png" alt="Gentoo Linux Logo">
+ </object>
+ </a>
+ <span class="site-label">Grumpy</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ <nav class="tyrian-navbar" role="navigation">
+ <div class="container">
+ <div class="row">
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>{# FIXME: What are these supposed to do in Tyrian? #}
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ </div>
+ <div class="collapse navbar-collapse navbar-main-collapse">
+ <ul class="nav navbar-nav">
+ {# FIXME: Add class="active" to "li" when we are on the given page already #}
+ <li><a href="/">Home</a></li>
+ {# TODO: Add other pages, potentially by iterating FlaskView's + some metadata in them (sequence or hide_navigation) instead of hardcoding #}
+ </ul>
+ </div>
+ </div>
+ </nav>
+
+<div class="container">
+ <div class="row">
+ <div class="col-xs-12">
+ {% block content %}{% endblock %}
+ </div>
+ </div>
+</div>
+
+</header>
+</body>
+</html> \ No newline at end of file
diff --git a/frontend/templates/index.html b/frontend/templates/index.html
new file mode 100644
index 0000000..782f407
--- /dev/null
+++ b/frontend/templates/index.html
@@ -0,0 +1,22 @@
+{% extends "base.html" %}
+{% block content %}
+
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">
+ <span class="fa fa-fw fa-cubes"></span>Known categories
+ </h3>
+ </div>
+ <div class="table-responsive">
+ <table class="table table-striped">
+ {% for category in categories -%}
+ <tr>
+ <td class="text-nowrap">{{ category.name }}</td>
+ <td>{{ category.description }}</td>
+ </tr>
+ {%- endfor %}
+ </table>
+ </div>
+</div>
+
+{% endblock %} \ No newline at end of file