Commit bb07f5687c7b2aeba3759304842b7f05bb3ed807
- Diff rendering mode:
- inline
- side by side
mouchak/classes/field.py
(4 / 4)
  | |||
8 | 8 | ||
9 | 9 | def __init__(self): | |
10 | 10 | """@todo: to be defined1 """ | |
11 | self.id = object.id | ||
12 | self.tags = object.tags | ||
13 | self.type = object.type | ||
14 | self.body = object.body | ||
11 | self.id = object.id | ||
12 | self.tags = object.tags | ||
13 | self.type = object.type | ||
14 | self.body = object.body |
mouchak/sampleConf.py
(3 / 0)
  | |||
7 | 7 | ''' | |
8 | 8 | HOST = '0.0.0.0' | |
9 | 9 | PORT = 5000 | |
10 | SECRET_KEY = 'a-uuid-string-see-python-uuid' | ||
11 | ADMIN_USERNAME = 'youradminusername' | ||
12 | ADMIN_PASSWORD = 'youradminpassword' |
mouchak/server.py
(37 / 2)
  | |||
49 | 49 | ||
50 | 50 | @app.route('/edit', methods=['GET']) | |
51 | 51 | def edit(): | |
52 | return flask.render_template('editor.html', content=getContent(), | ||
53 | title=conf.SITE_TITLE) | ||
52 | if "logged_in" in flask.session: | ||
53 | flask.session['key'] = conf.SECRET_KEY | ||
54 | return flask.render_template('editor.html', content=getContent(), | ||
55 | title=conf.SITE_TITLE) | ||
56 | else: | ||
57 | return flask.redirect(flask.url_for('login')) | ||
54 | 58 | ||
55 | 59 | ||
56 | 60 | @app.route('/page', methods=['POST']) | |
… | … | ||
108 | 108 | def updateMenu(_id): | |
109 | 109 | if flask.request.method == 'PUT': | |
110 | 110 | changedMenu = flask.request.json | |
111 | print "changed menu:" | ||
111 | 112 | print changedMenu | |
112 | 113 | res = siteMenu.update({'_id': bson.ObjId(_id)}, changedMenu) | |
113 | 114 | print res | |
… | … | ||
122 | 122 | # return flask.jsonify(status='deleted') | |
123 | 123 | ||
124 | 124 | ||
125 | # Basic login for one single admin user whose credentials are in conf.py | ||
126 | @app.route('/login', methods=['GET', 'POST']) | ||
127 | def login(): | ||
128 | error = None | ||
129 | if flask.request.method == 'POST': | ||
130 | print flask.request.form | ||
131 | if flask.request.form['username'] != conf.ADMIN_USERNAME: | ||
132 | error = 'Invalid username' | ||
133 | elif flask.request.form['password'] != conf.ADMIN_PASSWORD: | ||
134 | error = 'Invaid password' | ||
135 | else: | ||
136 | flask.session['logged_in'] = True | ||
137 | flask.session['key'] = conf.SECRET_KEY | ||
138 | flask.flash('You were logged in') | ||
139 | return flask.redirect(flask.url_for('edit')) | ||
140 | return flask.render_template('login.html', error=error) | ||
141 | |||
142 | @app.route('/logout') | ||
143 | def logout(): | ||
144 | flask.session.pop('logged_in', None) | ||
145 | flask.flash('You were logged out') | ||
146 | return flask.redirect(flask.url_for('login')) | ||
147 | |||
148 | @app.route('/robots.txt') | ||
149 | @app.route('/crossdomain.xml') | ||
150 | def static_from_root(): | ||
151 | return flask.send_from_directory(app.static_folder, request.path[1:]) | ||
152 | |||
153 | |||
154 | app.config.from_object(conf) | ||
125 | 155 | ||
126 | 156 | if __name__ == "__main__": | |
127 | 157 | app.run(debug=True, host=conf.HOST, port=conf.PORT) |
  | |||
23 | 23 | <![endif]--> | |
24 | 24 | ||
25 | 25 | <div class="container" id="container"> | |
26 | <div id="header"><div id="notifications"></div></div> | ||
27 | <div id="content-container"></div> | ||
26 | <div id="header"> | ||
27 | <div id="hud"> | ||
28 | <span class="pull-right">Howdy! | <a href="/logout">Logout</a></span> | ||
29 | </div> | ||
30 | <div id="notifications"></div> | ||
31 | </div> | ||
32 | <div id="content-container"> | ||
33 | </div> | ||
28 | 34 | <div id="footer"> | |
29 | 35 | </div> | |
30 | 36 | </div> |
mouchak/templates/login.html
(64 / 0)
  | |||
1 | <!DOCTYPE html> | ||
2 | <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | ||
3 | <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> | ||
4 | <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> | ||
5 | <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> | ||
6 | <head> | ||
7 | <meta charset="utf-8"> | ||
8 | <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
9 | <title> Mouchak | Login</title> | ||
10 | <meta name="description" content=""> | ||
11 | <meta name="viewport" content="width=device-width"> | ||
12 | |||
13 | <!-- Place favicon.ico in the root directory --> | ||
14 | |||
15 | <link rel="stylesheet" href="/static/css/normalize.css"> | ||
16 | <link rel="stylesheet" href="/static/css/bootstrap.css"> | ||
17 | <style type="text/css"> | ||
18 | .form-wrapper { | ||
19 | height: 300px; | ||
20 | width: 500px; | ||
21 | margin: 100px auto; | ||
22 | padding: 30px; | ||
23 | } | ||
24 | </style> | ||
25 | </head> | ||
26 | <body> | ||
27 | <!--[if lt IE 7]> | ||
28 | <p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p> | ||
29 | <![endif]--> | ||
30 | |||
31 | <div class="container" id="container"> | ||
32 | <div class="form-wrapper well"> | ||
33 | {% if error %} | ||
34 | <div class="alert alert-error"><b>Error:</b> {{ error }} </div> | ||
35 | {% endif %} | ||
36 | <h3> Mouchak Login </h3> | ||
37 | <p class="lead"> Please enter admin credentials to login</p> | ||
38 | <form class="form-horizontal" action="{{ url_for('login') }}" method="POST"> | ||
39 | <div class="control-group"> | ||
40 | <label class="control-label" for="inputUsername">Username</label> | ||
41 | <div class="controls"> | ||
42 | <input type="text" id="inputUsername" name="username" placeholder="Username"> | ||
43 | </div> | ||
44 | </div> | ||
45 | <div class="control-group"> | ||
46 | <label class="control-label" for="inputPassword">Password</label> | ||
47 | <div class="controls"> | ||
48 | <input type="password" id="inputPassword" name="password" placeholder="Password"> | ||
49 | </div> | ||
50 | </div> | ||
51 | <div class="control-group"> | ||
52 | <div class="controls"> | ||
53 | <!--label class="checkbox"> | ||
54 | <input type="checkbox"> Remember me | ||
55 | </label--> | ||
56 | <button type="submit" class="btn btn-primary">Login</button> | ||
57 | </div> | ||
58 | </div> | ||
59 | <div class="clearfix"></div> | ||
60 | </form> | ||
61 | </div> | ||
62 | </div> | ||
63 | </body> | ||
64 | </html> |