Merge branch 'master' of github.com:ajwillia-ms/extra-server

This commit is contained in:
Andy Williams 2016-07-04 22:16:34 +00:00
commit a76d276883
10 changed files with 203 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
env

46
app/__init__.py Normal file
View File

@ -0,0 +1,46 @@
from flask import Flask
from flask import abort, render_template
from flask_restful import Resource, Api, abort as api_abort
app = Flask(__name__)
api = Api(app)
@app.route('/')
def welcome():
return render_template('welcome.html')
@app.route('/about/')
def about():
return render_template('about.html')
THEMES = {
'1': {'theme_id': '1'},
'a': {'theme_id': 'a'},
}
class ThemeList(Resource):
def get(self):
return THEMES
class Theme(Resource):
def get(self, theme_id):
if theme_id not in THEMES:
api_abort(404, message="Theme {} not found".format(theme_id))
return THEMES[theme_id]
@app.route('/themes/')
@app.route('/themes/<theme_id>')
def themes(theme_id=None):
if theme_id:
if theme_id not in THEMES:
abort(404)
return render_template('theme.html', theme_id=theme_id)
else:
return render_template('themes.html', themes=THEMES)
api.add_resource(ThemeList, '/v1/themes/')
api.add_resource(Theme, '/v1/themes/<string:theme_id>')
if __name__ == '__main__':
app.run(debug=True)

9
app/templates/about.html Normal file
View File

@ -0,0 +1,9 @@
{% extends "layout.html" %}
{% block title %}About{% endblock %}
{% block heading %}About{% endblock %}
{% block content %}
<p>Extra is an Enlightenment site for discovering and downloading themes
and other great add-ons to the Enlightenment desktop.</p>
{% endblock %}

101
app/templates/layout.html Normal file
View File

@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>{% block title %}{% endblock %} - Extra Enlightenment</title>
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
<meta name="generator" content="DokuWiki"http://enlightenment.org/>
<meta name="robots" content="index,follow"http://enlightenment.org/>
<meta name="keywords" content="start"http://enlightenment.org/>
<link rel="search" type="application/opensearchdescription+xml" href="http://enlightenment.org/lib/exe/opensearch.php" title=""/>
<link rel="start" href="http://enlightenment.org/"/>
<link rel="contents" href="http://enlightenment.org/start?do=index" title="Sitemap"/>
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="http://enlightenment.org/feed.php"/>
<link rel="alternate" type="application/rss+xml" title="Current namespace" href="http://enlightenment.org/feed.php?mode=list&amp;ns="/>
<link rel="edit" title="Edit this page" href="http://enlightenment.org/start?do=edit"/>
<link rel="alternate" type="text/html" title="Plain HTML" href="http://enlightenment.org/_export/xhtml/start"/>
<link rel="alternate" type="text/plain" title="Wiki Markup" href="http://enlightenment.org/_export/raw/start"/>
<link rel="canonical" href="https://www.enlightenment.org/"http://enlightenment.org/>
<link rel="stylesheet" type="text/css" href="http://enlightenment.org/lib/exe/css.php?t=e&amp;tseed=905991e55e329084d608eaa4c2a5f680"/>
<script type="text/javascript">/*<![CDATA[*/var NS='';var SIG=' --- //[[andy@andywilliams.me|Andrew Williams]] //';var JSINFO = {"id":"start","namespace":"","plugin_folded":{"hide":"hide","reveal":"reveal"}};
/*!]]>*/</script>
<script type="text/javascript" charset="utf-8" src="http://enlightenment.org/lib/exe/js.php?tseed=905991e55e329084d608eaa4c2a5f680"></script>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="shortcut icon" href="http://enlightenment.org/lib/tpl/e/images/favicon.ico" />
<link rel="apple-touch-icon" href="http://enlightenment.org/lib/tpl/e/images/apple-touch-icon.png" />
<!-- meta content goes here -->
<link href="http://enlightenment.org/lib/tpl/e/css/bootstrap-default.min.css" rel="stylesheet">
<link href="http://enlightenment.org/lib/tpl/e/css/modifications.css" rel="stylesheet">
<script src="http://enlightenment.org/lib/tpl/e/js/bootstrap.min.js"></script>
<script src="http://enlightenment.org/lib/tpl/e/js/modifications.js"></script>
<link href='//fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="dokuwiki__site">
<div id="dokuwiki__top" class="dokuwiki site mode_show"></div>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://enlightenment.org/"></a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-left">
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/themes/">Themes</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<!--
<div class="navbar-form form-group" role="search">
<form action="http://enlightenment.org/start" accept-charset="utf-8" class="search" id="dw__search" method="get"><div class="no"><input type="hidden" name="do" value="search" /><input class="" type="text" placeholder="Search" autocomplete="off" id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" /><button type="submit" value="" class="btn btn-default" title="Search"><i class="glyphicon glyphicon-search"></i></button></div></form> </div>
-->
</li>
</ul>
</div>
</div> <!-- container -->
</nav> <!-- navbar -->
<div class="container">
<div class="row">
<div class="col-md-11" id="dokuwiki__content">
<div class="page">
<h3>{% block heading %}{% endblock %}</h3>
<div class="level3">
{% block content %}TODO{% endblock %}
</div>
</div>
</div>
</div><!-- row -->
</div><!-- container -->
<div class="clearer"></div>
<hr class="a11y" />
<!-- ********** FOOTER ********** -->
<footer>
<div class="clearer"></div>
<div class="container">
<div class="row">
<div class="col-md-11 text-muted text-right">
</div>
</div>
</div>
</footer>
</div>
</body>
</html>

3
app/templates/theme.html Normal file
View File

@ -0,0 +1,3 @@
{% extends "layout.html" %}
{% block title %}Theme {{ theme_id }}{% endblock %}
{% block heading %}Theme - {{ theme_id }}{% endblock %}

11
app/templates/themes.html Normal file
View File

@ -0,0 +1,11 @@
{% extends "layout.html" %}
{% block title %}Themes{% endblock %}
{% block heading %}Themes{% endblock %}
{% block content %}
<ul>
{% for theme_id in themes %}
<li><a href="{{ theme_id }}">theme {{ themes[theme_id].theme_id }}</a></li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "layout.html" %}
{% block title %}Welcome{% endblock %}
{% block heading %}Welcome{% endblock %}
{% block content %}
<ul>
<li><a href="/themes/">Themes</a></li>
</ul>
<p><a href="/about/">About</a> Extra Enlightenment.</p>
{% endblock %}

7
config.py Normal file
View File

@ -0,0 +1,7 @@
# Statement for enabling the development environment
DEBUG = True
# Define the application directory
import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))

11
requirements.txt Normal file
View File

@ -0,0 +1,11 @@
aniso8601==1.1.0
click==6.6
Flask==0.11.1
Flask-RESTful==0.3.5
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
python-dateutil==2.5.3
pytz==2016.4
six==1.10.0
Werkzeug==0.11.10

3
run.py Normal file
View File

@ -0,0 +1,3 @@
# Run a test server.
from app import app
app.run(host='0.0.0.0', port=8080, debug=True)