Commit 18b27957b4e4ac89a53323576d86e71ec6da42c3

Small fixes. Still custom menu doesn't work.

  - small fixes in the UI code.
  - lot of logging to debug custom menu
  • Diff rendering mode:
  • inline
  • side by side

mouchak.conf

1DB=test_mouchak
2SITE_TITLE=Testing Mouchak
1DB=crin
2SITE_TITLE=Community Radio | India
3HOST=0.0.0.03HOST=0.0.0.0
4PORT=50004PORT=5000

server.py

107 print changedMenu107 print changedMenu
108 res = siteMenu.update({'_id': bson.ObjId(_id)}, changedMenu)108 res = siteMenu.update({'_id': bson.ObjId(_id)}, changedMenu)
109 print res109 print res
110 return flask.jsonify(status='ok',menu=changedMenu)
110 return flask.jsonify(status='ok', menu=changedMenu)
111111
112 #elif flask.request.method == 'DELETE':112 #elif flask.request.method == 'DELETE':
113 # delMenu = flask.request.url113 # delMenu = flask.request.url

static/js/editor.js

255 $('#specific-content').html(template({255 $('#specific-content').html(template({
256 data: this.model.get('data')256 data: this.model.get('data')
257 }));257 }));
258 // init the tinymce editor
259 tinymce.init({
260 selector: '#edit',
261 theme: 'modern',
262 height: 300,
263 plugins: ["advlist autolink link image lists charmap print preview hr",
264 "anchor pagebreak spellchecker searchreplace wordcount",
265 "visualblocks visualchars code fullscreen insertdatetime",
266 "media nonbreaking save table contextmenu directionality",
267 "emoticons template paste textcolor"
268 ],
269 toolbar: "undo redo | styleselect | bold italic | " +
270 "alignleft aligncenter alignright alignjustify | " +
271 "bullist numlist outdent indent | link image | " +
272 "print preview media fullpage | forecolor backcolor emoticons"
273
274 });
258 // init the wysiwig editor
259 M.editor.wysiwig('#edit');
275 } 260 }
276 else if(type === 'image' || type === 'video' || type === 'audio') {261 else if(type === 'image' || type === 'video' || type === 'audio') {
277 var template = _.template($('#media-template').html());262 var template = _.template($('#media-template').html());
333333
334 if(this.model.get('customMenu') === true) {334 if(this.model.get('customMenu') === true) {
335 $('#custom-menu').attr('checked', true);335 $('#custom-menu').attr('checked', true);
336 this.$menuOptions.show();
336 this.$menuOptions.show({complete: function() {
337 M.editor.wysiwig('#menu');
338 }});
337 }339 }
338 },340 },
339 showMenuOptions: function(bool) {341 showMenuOptions: function(bool) {
340 if(bool === true) {342 if(bool === true) {
341 this.$menuOptions.show();
343 this.$menuOptions.show({complete: function() {
344 //M.editor.wysiwig('#menu');
345 }});
342 }346 }
343 else {347 else {
344 this.$menuOptions.hide();348 this.$menuOptions.hide();
359 this.showMenuOptions(this.model.get('customMenu'));359 this.showMenuOptions(this.model.get('customMenu'));
360 },360 },
361 saveMenu: function() {361 saveMenu: function() {
362 var menuHTML = $('#menu').val().trim();
363 this.model.set({'html': menuHTML});
364 console.log(this.model.toJSON());
365 this.model.save({}, {
362 //console.log('saving menu..');
363 // var menuHTML = $('#menu').val().trim();
364 //this.model.set({'html': menuHTML});
365 //console.log(this.model.toJSON());
366 //alert('saveMenu called');
367 /*this.model.save({}, {
366 success: function(model, response) {368 success: function(model, response) {
369 console.log(model, response);
367 },370 },
368 error: function(xhr, response) {371 error: function(xhr, response) {
369 }372 }
370 });
373 });*/
374 //alert('end of save menu');
371 }375 }
372 });376 });
373377
384 pagelistview.render();384 pagelistview.render();
385 });385 });
386 M.pagelistview = pagelistview;386 M.pagelistview = pagelistview;
387 },
388 wysiwig: function($selector) {
389 tinymce.init({
390 selector: $selector,
391 theme: 'modern',
392 height: 300,
393 plugins: ["advlist autolink link image lists charmap print preview hr",
394 "anchor pagebreak spellchecker searchreplace wordcount",
395 "visualblocks visualchars code fullscreen insertdatetime",
396 "media nonbreaking save table contextmenu directionality",
397 "emoticons template paste textcolor"
398 ],
399 toolbar: "undo redo | styleselect | bold italic | " +
400 "alignleft aligncenter alignright alignjustify | " +
401 "bullist numlist outdent indent | link image | " +
402 "print preview media fullpage | forecolor backcolor emoticons"
403 });
387 }404 }
388 };405 };
389406

static/js/mouchak.js

49 console.log('rendering custom menu..');49 console.log('rendering custom menu..');
50 this.$el.append(this.model.get('html'));50 this.$el.append(this.model.get('html'));
51 }51 }
52 this.$links = $('.nav li');
53 if(!this.$links) {
54 throw new Error('Ill-formed menu! Please check you have <ul> element' +
55 'inside your menu with class nav and <li> elements inside it');
56 alert('Error in Menu: Please check console for details');
57 }
52 var fragment = location.hash.split('/')[1];58 var fragment = location.hash.split('/')[1];
53 var pos = _.indexOf(M.pages.models, M.pages.where({'name': fragment})[0]);59 var pos = _.indexOf(M.pages.models, M.pages.where({'name': fragment})[0]);
54 if(!fragment) {60 if(!fragment) {
71 page: page.get('name')71 page: page.get('name')
72 }));72 }));
73 }, this);73 }, this);
74 this.$links = $('.nav li');
75 },74 },
76 navClicked: function(event) {75 navClicked: function(event) {
77 this.$links.removeClass('active');76 this.$links.removeClass('active');

templates/editor.html

70 </div>70 </div>
71 </div>71 </div>
72 <label><strong> HTML </strong></label>72 <label><strong> HTML </strong></label>
73 <textarea id="menu">
73 <div id="menu">
74 <%= menu %>74 <%= menu %>
75 </textarea>
75 </div>
76 </div>76 </div>
77 </form>77 </form>
78 </div>78 </div>