Commit 24cd97ed92bbb6fc321663ad68a08ded9a88f082
- Diff rendering mode:
- inline
- side by side
mouchak/server.py
(6 / 3)
  | |||
71 | 71 | del(newpage['_id']) | |
72 | 72 | print newpage | |
73 | 73 | # FIXME: handle errors | |
74 | return flask.jsonify(status='ok', page=newpage) | ||
74 | #return flask.jsonify(status='ok', page=newpage) | ||
75 | return flask.jsonify(newpage) | ||
75 | 76 | ||
76 | 77 | ||
77 | 78 | @app.route('/page/<_id>', methods=['PUT', 'DELETE']) | |
… | … | ||
86 | 86 | print res | |
87 | 87 | if res['err'] == None: | |
88 | 88 | print changedPage | |
89 | return flask.jsonify(status='ok', page=changedPage) | ||
89 | #return flask.jsonify(status='ok', page=changedPage) | ||
90 | return flask.jsonify(changedPage) | ||
90 | 91 | ||
91 | 92 | elif flask.request.method == 'DELETE': | |
92 | 93 | delPage = flask.request.url | |
… | … | ||
119 | 119 | print changedMenu | |
120 | 120 | res = siteMenu.update({'_id': bson.ObjId(_id)}, changedMenu) | |
121 | 121 | print res | |
122 | return flask.jsonify(status='ok', menu=changedMenu) | ||
122 | #return flask.jsonify(status='ok', menu=changedMenu) | ||
123 | return flask.jsonify(changedMenu) | ||
123 | 124 | ||
124 | 125 | #elif flask.request.method == 'DELETE': | |
125 | 126 | # delMenu = flask.request.url |
mouchak/static/js/editor.js
(18 / 10)
  | |||
30 | 30 | this.$pagelist.html(''); | |
31 | 31 | _.each(M.pages.models, function(page) { | |
32 | 32 | this.$pagelist.append(this.listTemplate({ | |
33 | name: page.get('name') || 'newpage', | ||
33 | name: page.get('name'), | ||
34 | 34 | id: page.id | |
35 | 35 | })); | |
36 | 36 | }, this); | |
… | … | ||
42 | 42 | M.editor.pageview = pageview; | |
43 | 43 | }, | |
44 | 44 | addPage: function() { | |
45 | var newpage = new M.types.model.Page(); | ||
45 | var newpage = new M.types.model.Page({name: 'newpage'}); | ||
46 | 46 | M.pages.add(newpage); | |
47 | var newpageview = new PageView({model: newpage}); | ||
48 | newpageview.render(); | ||
49 | M.editor.pageview = newpageview; | ||
47 | var self = this; | ||
48 | M.editor.showOverlay(); | ||
49 | newpage.save({}, {success: function(model, response) { | ||
50 | M.editor.hideOverlay(); | ||
51 | self.render(); | ||
52 | var newpageview = new PageView({model: newpage}); | ||
53 | newpageview.render(); | ||
54 | M.editor.pageview = newpageview; | ||
55 | }}); | ||
50 | 56 | }, | |
51 | 57 | removePage: function(event) { | |
52 | 58 | var option = confirm("Are you sure, you want to delete this page?"); | |
… | … | ||
214 | 214 | ||
215 | 215 | this.editing = false; | |
216 | 216 | this.edit_idx = -1; | |
217 | //console.log('setting content in page: ', content); | ||
218 | 217 | this.model.set({'content': content}); | |
219 | 218 | this.render(); | |
220 | 219 | }, | |
… | … | ||
246 | 246 | this.model.set({'showNav': false}); | |
247 | 247 | } | |
248 | 248 | ||
249 | //console.log('mode before save', this.model.toJSON()); | ||
250 | |||
249 | 251 | this.model.save({}, { | |
250 | 252 | success: function(model, response) { | |
251 | 253 | //console.log('saved', model, response); | |
252 | 254 | M.editor.hideOverlay(); | |
253 | model.set(response.page); | ||
254 | model.id = response.page.id; | ||
255 | //model.set(response.page); | ||
256 | //model.id = response.page.id; | ||
257 | //console.log(model); | ||
255 | 258 | M.pagelistview.render(); | |
256 | 259 | $('#notifications').html(success_template({ | |
257 | 260 | title: 'Saved', | |
… | … | ||
503 | 503 | M.pages = new Pages(M.site_content.content); | |
504 | 504 | var pagelistview = new PageListView(); | |
505 | 505 | pagelistview.render(); | |
506 | M.pages.on('add', function(page) { | ||
506 | /*M.pages.on('add', function(page) { | ||
507 | 507 | pagelistview.render(); | |
508 | }); | ||
508 | });*/ | ||
509 | 509 | M.pagelistview = pagelistview; | |
510 | 510 | }, | |
511 | 511 | wysiwyg: { |