Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

outlined future javascript layout

  • Loading branch information...
commit 09a8c33ea7aeb90658d6486161e9c2728cd5eb66 1 parent 800c632
@Zottel authored
View
12 startzeile/web/__init__.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8
+
# Flask
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
@@ -10,7 +12,7 @@ def create_app(startzeile, config):
# Default page - only needed when visited by user => only html
@app.route('/')
- @app.route('/index.html')
+ #@app.route('/index.html')
def show_default():
return render_template('index.xhtml')
@@ -30,17 +32,17 @@ def show_default():
app.add_url_rule('/query.<filetype>',
view_func=query_view,
- defaults = {'querytype': 'post'},
+ defaults = {'querytype': 'post'},
methods=['POST'])
app.add_url_rule('/query/all.<filetype>',
view_func=query_view,
- defaults = {'querytype': 'all'},
+ defaults = {'querytype': 'all'},
methods=['GET'])
app.add_url_rule('/query/tags/<path:tags>.<filetype>',
view_func=query_view,
- defaults = {'querytype': 'tags'},
+ defaults = {'querytype': 'tags'},
methods=['GET'])
# Tag view + url handling
@@ -57,5 +59,5 @@ def show_default():
return app
# Submodules
-__all__ = ['views']
+__all__ = ['link', 'tag', 'query']
View
12 startzeile/web/link.py
@@ -1,28 +1,26 @@
# -*- coding: utf-8
+
from flask.views import View, MethodView
from flask import request, session, g, redirect, render_template, flash
-
class RESTLink(MethodView):
-
def get(self, filetype, link_id = None):
return render_template('link.xhtml')
# TODO: return the requested link
pass
-
+
def post(self, filetype):
# TODO: Create link
pass
-
+
def delete(self, filetype, link_id):
# TODO: Delete Link
pass
-
+
def put(self, filetype, link_id):
# TODO: Update Link
pass
-
+
def __init__(self, startzeile):
self.startzeile = startzeile
- pass
View
2  startzeile/web/query.py
@@ -10,7 +10,7 @@ def __init__(self, startzeile):
self.startzeile = startzeile
pass
- def dispatch_request(self, querytype, filetype, tags):
+ def dispatch_request(self, querytype, filetype, tags = None):
return render_template('default.xhtml')
pass
View
72 startzeile/web/static/js/startzeile.js
@@ -1,23 +1,73 @@
function Startzeile(config) {
+ // Hooks
+ this.hooks = {};
+ this.addHook = function(event, callback){
+ if(this.hooks[event] === undefined){
+ this.hooks[event] = [];
+ }
+
+ this.hooks[event].push(callback);
+ }
+ this.delHook = function(event, callback){
+ if(this.hooks[event] !== undefined){
+ var index = this.hooks[event].indexOf(callback);
+ if(index != -1){
+ this.hooks[event].splice(index, 1);
+ }
+ }
+ }
+ this.callHook = function(event, data){
+ if(this.hooks[event] !== undefined){
+ this.hooks[event].forEach(function(callback){
+ callback(data);
+ });
+ }
+ };
}
-function Search(startzeile, initial) {
- if(initial == undefined) {
- initial = 'search here';
- }
+function ResultList(startzeile, default_results) {
+ var shown = false;
+ var pages_container = undefined;
+ var tags_container = undefined;
- this.show = function(container) {
+ this.show = function(p_container, t_container) {
+ pages_container = p_container; tags_container = t_container;
- }
-
- this.query = function(str) {
+ $(pages_container).empty();
+ $(tags_container).empty();
}
+
+ this.resultPages(pages) {
+ console.debug('resultPages', pages')
+ if(pages_container === undefined) {
+ return;
+ }
+ }
+
+ this.resultTags(tags) {
+ console.debug('resultTags', tags')
+ if(tags_container === undefined) {
+ return;
+ }
+ }
+
+ //Setup
+ startzeile.addHook('resultPages',
+ $.proxy(this.resultPages, this));
+
+ startzeile.addHook('resultTags',
+ $.proxy(this.resultTags, this));
}
-function ResultList(startzeile, results) {
- this.show = function(container) {
-
+function Searchbox(startzeile, default_search) {
+ var shown = false;
+
+ this.show = function(search_container) {
+ $(default_search).
}
+
+ // Setup
+
}
View
31 startzeile/web/templates/default.xhtml
@@ -14,24 +14,39 @@
<script type="text/javascript">
<!--//--><![CDATA[//><!--
$(function(){
- var config = {
- title: {{ config.TITLE if config.TITLE else ''|tojson|safe}}
- };
+ var config = {interface: {query: {all: {}, post: {}, tags: {}}}};
+ config.title = {{ config.TITLE if config.TITLE else ''|tojson|safe}};
+ config.interface.query.all.html = '{{ url_for('query_api', querytype = 'all', filetype='html') }}';
+ config.interface.query.all.json = '{{ url_for('query_api', querytype = 'all', filetype='json') }}';
+ config.interface.query.post.html = '{{ url_for('query_api', querytype = 'post', filetype='html') }}';
+ config.interface.query.post.json = '{{ url_for('query_api', querytype = 'post', filetype='json') }}';
+ config.interface.query.tags.html = '{{ url_for('query_api', querytype = 'tags', tags='', filetype='html') }}';
+ config.interface.query.tags.json = '{{ url_for('query_api', querytype = 'tags', tags='', filetype='json') }}';
+
Startzeile = new Startzeile(config);
+
{% block script %}
{% endblock %}
+
+
});
//--><!]]>
- </script>
+ </script>
</head>
<body>
- <h1>Startzeile</h1>
- <form method="POST" action="{{ url_for('query_api', type='html') }}">
+ <h1><a href="{{ url_for('show_default') }}">Startzeile</a></h1>
+ <form method="POST" action="{{ url_for('query_api', querytype = 'post', filetype='html') }}">
<input type="text" name="query" />
</form>
-
- {% block content %}
+ <ul class="result_tags">
+ {% block result_tags %}
+
+ {% endblock %}
+ </ul>
+ <ul class="result_pages">
+ {% block result_pages %}
{% endblock %}
+ </ul>
</body>
</html>
View
5 startzeile/web/templates/index.xhtml
@@ -0,0 +1,5 @@
+{% extends "default.xhtml" %}
+
+{% block title %}{% endblock %}
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.