From b0a45c4865edf866ff3fa9c4d497f02e77c28e73 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 14 Oct 2013 18:14:41 +0530 Subject: [PATCH] [web page] make editable for logged in user (alpha) --- public/js/lib/bootstrap-wysiwyg.js | 8 +++++++- public/js/wn/form/editors.js | 1 - public/js/wn/views/reportview.js | 2 +- webnotes/client.py | 6 +++--- website/css/website.css | 6 ++++++ .../doctype/web_page/templates/generators/web_page.html | 8 ++++++++ 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/public/js/lib/bootstrap-wysiwyg.js b/public/js/lib/bootstrap-wysiwyg.js index d3a0840e32..5bc4134155 100644 --- a/public/js/lib/bootstrap-wysiwyg.js +++ b/public/js/lib/bootstrap-wysiwyg.js @@ -22,7 +22,13 @@ jQuery(function ($) { }; $.fn.cleanHtml = function () { var html = $(this).html(); - return html && html.replace(/(
|\s|

<\/div>| )*$/, ''); + html = html && html.replace(/(
|\s|

<\/div>| )*$/, ''); + + // remove custom typography (use CSS!) + html = html && html.replace(/(font-family|font-size|line-height):[^;]*;/g, ''); + html = html && html.replace(/<[^>]*(font=['"][^'"]*['"])>/g, function(a,b) { return a.replace(b, ''); }); + html = html && html.replace(/\s*style\s*=\s*["']\s*["']/g, ''); + return html; }; $.fn.wysiwyg = function (userOptions) { var editor = this, diff --git a/public/js/wn/form/editors.js b/public/js/wn/form/editors.js index e5cb266d8d..d46813f9f3 100644 --- a/public/js/wn/form/editors.js +++ b/public/js/wn/form/editors.js @@ -157,7 +157,6 @@ wn.editors.BootstrapWYSIWYG = Class.extend({ me.$textarea.val(html_beautify(me.$editor.cleanHtml())); me.$parent.find(".for-rich-text").toggle(false); me.$parent.find(".for-html").toggle(true); - console.log(me.$parent.find(".btn-html")); me.$parent.find(".btn-html").attr("disabled", "disabled"); me.$parent.find(".btn-rich-text").attr("disabled", false); me.current_editor = me.$textarea; diff --git a/public/js/wn/views/reportview.js b/public/js/wn/views/reportview.js index c7c9644ebb..61aea427ac 100644 --- a/public/js/wn/views/reportview.js +++ b/public/js/wn/views/reportview.js @@ -287,7 +287,7 @@ wn.views.ReportView = wn.ui.Listing.extend({ method: "webnotes.client.set_value", args: { doctype: docfield.parent, - docname: row[docfield.parent===me.doctype ? "name" : docfield.parent+":name"], + name: row[docfield.parent===me.doctype ? "name" : docfield.parent+":name"], fieldname: docfield.fieldname, value: d.get_value(docfield.fieldname) }, diff --git a/webnotes/client.py b/webnotes/client.py index df104a0a2a..eab6c2c4db 100644 --- a/webnotes/client.py +++ b/webnotes/client.py @@ -25,17 +25,17 @@ def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False): return webnotes.conn.get_value(doctype, json.loads(filters), fieldname, as_dict=as_dict, debug=debug) @webnotes.whitelist() -def set_value(doctype, docname, fieldname, value): +def set_value(doctype, name, fieldname, value): if fieldname in webnotes.model.default_fields: webnotes.throw(_("Cannot edit standard fields")) - doc = webnotes.conn.get_value(doctype, docname, ["parenttype", "parent"], as_dict=True) + doc = webnotes.conn.get_value(doctype, name, ["parenttype", "parent"], as_dict=True) if doc and doc.parent: bean = webnotes.bean(doc.parenttype, doc.parent) child = bean.doclist.getone({"doctype": doctype, "name": docname}) child.fields[fieldname] = value else: - bean = webnotes.bean(doctype, docname) + bean = webnotes.bean(doctype, name) bean.doc.fields[fieldname] = value bean.save() diff --git a/website/css/website.css b/website/css/website.css index 105d042cee..f33646ae70 100644 --- a/website/css/website.css +++ b/website/css/website.css @@ -191,4 +191,10 @@ fieldset { display: table-cell; vertical-align: middle; text-align: center; +} + +.web-page-editable { + margin: -15px; + padding: 15px; + border-radius: 4px; } \ No newline at end of file diff --git a/website/doctype/web_page/templates/generators/web_page.html b/website/doctype/web_page/templates/generators/web_page.html index 316cc7ca96..6063fad2c8 100644 --- a/website/doctype/web_page/templates/generators/web_page.html +++ b/website/doctype/web_page/templates/generators/web_page.html @@ -3,6 +3,14 @@ {% block content %}
{% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %} +
{{ main_section }} +
+ {% endblock %} \ No newline at end of file