From 3023a8fa9b258169bc073aab6644e8d93d565da0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 3 Apr 2013 16:34:23 +0530 Subject: [PATCH] [website] [cleanup] separated website generation in framework and erpnext --- config.json | 67 ++++++++++++++ startup/website.py | 39 --------- website/helpers/blog.py | 2 +- website/helpers/product.py | 2 +- website/templates/css/login.css | 43 --------- website/templates/html/base.html | 25 ------ website/templates/html/blog_page.html | 12 +-- website/templates/html/outer.html | 6 +- website/templates/html/page.html | 2 +- website/templates/html/product_group.html | 8 +- website/templates/html/product_in_list.html | 2 +- website/templates/html/product_page.html | 14 +-- website/templates/html/web_page.html | 4 +- website/templates/js/login.js | 97 --------------------- website/templates/pages/404.html | 14 --- website/templates/pages/about.html | 2 +- website/templates/pages/account.html | 2 +- website/templates/pages/attributions.html | 2 +- website/templates/pages/blog.html | 8 +- website/templates/pages/contact.html | 4 +- website/templates/pages/error.html | 13 --- website/templates/pages/index.html | 2 +- website/templates/pages/login.html | 62 ------------- website/templates/pages/message.html | 11 --- website/templates/pages/order.html | 2 +- website/templates/pages/orders.html | 2 +- website/templates/pages/print.html | 18 ---- website/templates/pages/product_search.html | 6 +- website/templates/pages/profile.html | 2 +- website/templates/pages/ticket.html | 2 +- website/templates/pages/tickets.html | 2 +- website/templates/pages/writers.html | 6 +- 32 files changed, 114 insertions(+), 369 deletions(-) delete mode 100644 website/templates/css/login.css delete mode 100644 website/templates/html/base.html delete mode 100644 website/templates/js/login.js delete mode 100644 website/templates/pages/404.html delete mode 100644 website/templates/pages/error.html delete mode 100644 website/templates/pages/login.html delete mode 100644 website/templates/pages/message.html delete mode 100644 website/templates/pages/print.html diff --git a/config.json b/config.json index 0f6bd0a5f9..ff6f80ffff 100644 --- a/config.json +++ b/config.json @@ -75,5 +75,72 @@ "label": "Knowledge Base", "icon": "icon-question-sign" } + }, + "web": { + "pages": { + "about": { + "template": "app/website/templates/pages/about", + "args_method": "website.doctype.about_us_settings.about_us_settings.get_args" + }, + "account": { + "template": "app/website/templates/pages/account" + }, + "attributions": { + "template": "app/website/templates/pages/attributions" + }, + "blog": { + "template": "app/website/templates/pages/blog", + "args_method": "website.helpers.blog.get_blog_template_args" + }, + "contact": { + "template": "app/website/templates/pages/contact", + "args_doctype": "Contact Us Settings" + }, + "index": { + "template": "app/website/templates/pages/index" + }, + "order": { + "no_cache": true, + "template": "app/website/templates/pages/order", + "args_method": "selling.doctype.sales_order.sales_order.get_website_args" + }, + "orders": { + "template": "app/website/templates/pages/orders", + "args_method": "selling.doctype.sales_order.sales_order.get_currency_and_number_format" + }, + "product_search": { + "template": "app/website/templates/pages/product_search" + }, + "ticket": { + "no_cache": true, + "template": "app/website/templates/pages/ticket", + "get_website_args": "support.doctype.support_ticket.support_ticket.get_website_args" + }, + "tickets": { + "template": "app/website/templates/pages/tickets" + }, + "writers": { + "template": "app/website/templates/pages/writers", + "args_method": "website.helpers.blog.get_writers_args" + } + }, + "generators": { + "Web Page": { + "template": "app/website/templates/html/web_page.html", + "condition_field": "published" + }, + "Blog Post": { + "template": "app/website/templates/html/blog_page.html", + "condition_field": "published" + }, + "Item": { + "template": "app/website/templates/html/product_page.html", + "condition_field": "show_in_website" + }, + "Item Group":{ + "template": "app/website/templates/html/product_group.html", + "condition_field": "show_in_website" + } + } } } \ No newline at end of file diff --git a/startup/website.py b/startup/website.py index 1041039d0e..295e5bb0ca 100644 --- a/startup/website.py +++ b/startup/website.py @@ -1,47 +1,8 @@ import webnotes, conf, os - def get_templates_path(): return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates") -standard_pages = [ - "404", "about", "account", "attributions", "blog", "contact", "error", "index", - "login", "message", "order", "orders", "print", "product_search", "profile", - "ticket", "tickets", "writers" -] - -page_map = { - 'Web Page': webnotes._dict({ - "template": 'html/web_page.html', - "condition_field": "published" - }), - 'Blog Post': webnotes._dict({ - "template": 'html/blog_page.html', - "condition_field": "published", - }), - 'Item': webnotes._dict({ - "template": 'html/product_page.html', - "condition_field": "show_in_website", - }), - 'Item Group': webnotes._dict({ - "template": "html/product_group.html", - "condition_field": "show_in_website" - }) -} - -page_settings_map = { - "about": "website.doctype.about_us_settings.about_us_settings.get_args", - "contact": "Contact Us Settings", - "blog": "website.helpers.blog.get_blog_template_args", - "writers": "website.helpers.blog.get_writers_args", - "print": "core.doctype.print_format.print_format.get_args", - "orders": "selling.doctype.sales_order.sales_order.get_currency_and_number_format", - "order": "selling.doctype.sales_order.sales_order.get_website_args", - "ticket": "support.doctype.support_ticket.support_ticket.get_website_args" -} - -no_cache = ["message", "print", "order", "ticket"] - def get_home_page(): doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page') if doc_name: diff --git a/website/helpers/blog.py b/website/helpers/blog.py index fb85e0dfe7..386c4b7f05 100644 --- a/website/helpers/blog.py +++ b/website/helpers/blog.py @@ -74,7 +74,7 @@ def add_comment(args=None): webnotes.webutils.clear_cache(args.get('page_name')) comment['comment_date'] = webnotes.utils.global_date_format(comment['creation']) - template_args = { 'comment_list': [comment], 'template': 'html/comment.html' } + template_args = { 'comment_list': [comment], 'template': 'app/website/templates/html/comment.html' } # get html of comment row comment_html = webnotes.webutils.build_html(template_args) diff --git a/website/helpers/product.py b/website/helpers/product.py index 4a1cd40e4d..d6f16fb753 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -82,7 +82,7 @@ def get_group_item_count(item_group): def get_item_for_list_in_html(r): scrub_item_for_list(r) - r.template = "html/product_in_list.html" + r.template = "app/website/templates/html/product_in_list.html" return build_html(r) def scrub_item_for_list(r): diff --git a/website/templates/css/login.css b/website/templates/css/login.css deleted file mode 100644 index 4120807022..0000000000 --- a/website/templates/css/login.css +++ /dev/null @@ -1,43 +0,0 @@ - \ No newline at end of file diff --git a/website/templates/html/base.html b/website/templates/html/base.html deleted file mode 100644 index cfba1a5ca0..0000000000 --- a/website/templates/html/base.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - {{ title }} - - - - - - - - - {% if description -%} - - {%- endif %} - {% block header -%} - {%- endblock %} - - - {% block body %} - {% endblock %} - - \ No newline at end of file diff --git a/website/templates/html/blog_page.html b/website/templates/html/blog_page.html index 270d427f7f..cf1f00e3be 100644 --- a/website/templates/html/blog_page.html +++ b/website/templates/html/blog_page.html @@ -1,11 +1,11 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% block javascript %} - {% include "js/blog_page.js" %} + {% include "app/website/templates/js/blog_page.js" %} {% endblock %} {% block css %} - {% include "css/blog_page.css" %} + {% include "app/website/templates/css/blog_page.css" %} {% endblock %} {% block content %} @@ -23,7 +23,7 @@ {% if blogger_info %}
- {% include "html/blogger.html" %} + {% include "app/website/templates/html/blogger.html" %} {% endif %}

{{ texts.comments }}


@@ -35,7 +35,7 @@ {% endif %} - {% include 'html/comment.html' %} + {% include 'app/website/templates/html/comment.html' %}
-{% include 'html/blog_footer.html' %} +{% include 'app/website/templates/html/blog_footer.html' %} {% endblock %} \ No newline at end of file diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html index 624371e4f5..570c7691c2 100644 --- a/website/templates/html/outer.html +++ b/website/templates/html/outer.html @@ -1,4 +1,4 @@ -{% extends "html/base.html" %} +{% extends "lib/templates/base.html" %} {% block body %}
@@ -10,13 +10,13 @@
{{ banner_html }}
{% endif %}
- {% include "html/navbar.html" %} + {% include "app/website/templates/html/navbar.html" %}
{%- block content -%} {%- endblock -%}
- {% include "html/footer.html" %} + {% include "app/website/templates/html/footer.html" %} {% endblock %} \ No newline at end of file diff --git a/website/templates/html/page.html b/website/templates/html/page.html index 9d38cdc859..c9fbec449a 100644 --- a/website/templates/html/page.html +++ b/website/templates/html/page.html @@ -1,4 +1,4 @@ -{% extends "html/outer.html" %} +{% extends "app/website/templates/html/outer.html" %} {% block title -%}{{ title }}{%- endblock %} diff --git a/website/templates/html/product_group.html b/website/templates/html/product_group.html index 510f9946ac..b3c851197e 100644 --- a/website/templates/html/product_group.html +++ b/website/templates/html/product_group.html @@ -1,11 +1,11 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% block content %} -{% include 'html/product_search_box.html' %} -{% include 'html/product_breadcrumbs.html' %} +{% include 'app/website/templates/html/product_search_box.html' %} +{% include 'app/website/templates/html/product_breadcrumbs.html' %}
{% if slideshow %} - {% include "html/slideshow.html" %} + {% include "app/website/templates/html/slideshow.html" %} {% endif %} {% if description %}
{{ description or ""}}
diff --git a/website/templates/html/product_in_list.html b/website/templates/html/product_in_list.html index bc6260795b..5cd9eace4e 100644 --- a/website/templates/html/product_in_list.html +++ b/website/templates/html/product_in_list.html @@ -4,7 +4,7 @@ {%- if website_image -%} {%- else -%} - {% include 'html/product_missing_image.html' %} + {% include 'app/website/templates/html/product_missing_image.html' %} {%- endif -%}
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html index f897a3120f..23091ad435 100644 --- a/website/templates/html/product_page.html +++ b/website/templates/html/product_page.html @@ -1,28 +1,28 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% block javascript %} - {% include "js/product_page.js" %} + {% include "app/website/templates/js/product_page.js" %} {% endblock %} {% block css %} - {% include "css/product_page.css" %} + {% include "app/website/templates/css/product_page.css" %} {% endblock %} {% block content %} - {% include 'html/product_search_box.html' %} - {% include 'html/product_breadcrumbs.html' %} + {% include 'app/website/templates/html/product_search_box.html' %} + {% include 'app/website/templates/html/product_breadcrumbs.html' %}
{% if slideshow %} - {% include "html/slideshow.html" %} + {% include "app/website/templates/html/slideshow.html" %} {% else %} {% if website_image %} {% else %}
- {% include 'html/product_missing_image.html' %} + {% include 'app/website/templates/html/product_missing_image.html' %}
{% endif %} {% endif %} diff --git a/website/templates/html/web_page.html b/website/templates/html/web_page.html index d3c646a8b8..6b8c914925 100644 --- a/website/templates/html/web_page.html +++ b/website/templates/html/web_page.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% block javascript %} {% if insert_code %} @@ -8,7 +8,7 @@ {% block content %}
- {% include "html/slideshow.html" %} + {% include "app/website/templates/html/slideshow.html" %} {{ main_section }}
{% endblock %} \ No newline at end of file diff --git a/website/templates/js/login.js b/website/templates/js/login.js deleted file mode 100644 index 06ea4c5242..0000000000 --- a/website/templates/js/login.js +++ /dev/null @@ -1,97 +0,0 @@ - -var login = {}; - -$(document).ready(function(wrapper) { - $('#login_btn').click(login.do_login) - - $('#password').keypress(function(ev){ - if(ev.which==13 && $('#password').val()) { - $('form').submit(function() { - login.do_login(); - return false; - }); - } - }); - $(document).trigger('login_rendered'); -}) - -// Login -login.do_login = function(){ - var args = {}; - if(window.is_sign_up) { - args.cmd = "core.doctype.profile.profile.sign_up"; - args.email = $("#login_id").val(); - args.full_name = $("#full_name").val(); - - if(!args.email || !valid_email(args.email) || !args.full_name) { - login.set_message("Valid email and name required."); - return false; - } - } else if(window.is_forgot) { - args.cmd = "reset_password"; - args.user = $("#login_id").val(); - - if(!args.user) { - login.set_message("Valid Login Id required."); - return false; - } - - } else { - args.cmd = "login" - args.usr = $("#login_id").val(); - args.pwd = $("#password").val(); - - if(!args.usr || !args.pwd) { - login.set_message("Both login and password required."); - return false; - } - } - - $('#login_btn').attr("disabled", "disabled"); - $("#login-spinner").toggle(true); - $('#login_message').toggle(false); - - $.ajax({ - type: "POST", - url: "server.py", - data: args, - dataType: "json", - success: function(data) { - $("input").val(""); - $("#login-spinner").toggle(false); - $('#login_btn').attr("disabled", false); - if(data.message=="Logged In") { - window.location.href = "app.html"; - } else if(data.message=="No App") { - window.location.href = "index"; - } else { - login.set_message(data.message); - } - } - }) - - return false; -} - -login.sign_up = function() { - $("#login_wrapper h3").html("Sign Up"); - $("#login-label").html("Email Id"); - $("#password-row, #sign-up-wrapper, #login_message").toggle(false); - $("#full-name-row").toggle(true); - $("#login_btn").html("Register"); - $("#forgot-wrapper").html("Login") - window.is_sign_up = true; -} - -login.show_forgot_password = function() { - $("#login_wrapper h3").html("Forgot"); - $("#login-label").html("Email Id"); - $("#password-row, #sign-up-wrapper, #login_message").toggle(false); - $("#login_btn").html("Send Password"); - $("#forgot-wrapper").html("Login") - window.is_forgot = true; -} - -login.set_message = function(message, color) { - $('#login_message').html(message).toggle(true); -} \ No newline at end of file diff --git a/website/templates/pages/404.html b/website/templates/pages/404.html deleted file mode 100644 index 8a676ce524..0000000000 --- a/website/templates/pages/404.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "html/outer.html" %} - -{% set title="Not Found" %} - -{% block content %} -
-
-

Page missing or moved

-
-

We are very sorry for this, but the page you are looking for is missing - (this could be because of a typo in the address) or moved.

-
-
-{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/about.html b/website/templates/pages/about.html index 380c5439ec..0cbd562ef9 100644 --- a/website/templates/pages/about.html +++ b/website/templates/pages/about.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title="About Us" %} diff --git a/website/templates/pages/account.html b/website/templates/pages/account.html index 8e8f4b4a07..fe2b8587ed 100644 --- a/website/templates/pages/account.html +++ b/website/templates/pages/account.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title="My Account" %} diff --git a/website/templates/pages/attributions.html b/website/templates/pages/attributions.html index 9e4b50ddce..05e8e8863e 100644 --- a/website/templates/pages/attributions.html +++ b/website/templates/pages/attributions.html @@ -1,4 +1,4 @@ -{% extends "html/outer.html" %} +{% extends "app/website/templates/html/outer.html" %} {% block header %} - - - {{ body }} - -{%- if comment -%} - -{%- endif -%} - \ No newline at end of file diff --git a/website/templates/pages/product_search.html b/website/templates/pages/product_search.html index 66bf160c94..2dab6ff4c2 100644 --- a/website/templates/pages/product_search.html +++ b/website/templates/pages/product_search.html @@ -1,9 +1,9 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title="Product Search" %} {% block javascript %} -{% include "js/product_list.js" %} +{% include "app/website/templates/js/product_list.js" %} {% endblock %} {% block content %} @@ -17,7 +17,7 @@ $(document).ready(function() { }); -{% include 'html/product_search_box.html' %} +{% include 'app/website/templates/html/product_search_box.html' %}

Search Results

diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html index 1b9350cf8c..d689cfb718 100644 --- a/website/templates/pages/profile.html +++ b/website/templates/pages/profile.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title="My Profile" %} diff --git a/website/templates/pages/ticket.html b/website/templates/pages/ticket.html index fe185f82ba..858dd3b338 100644 --- a/website/templates/pages/ticket.html +++ b/website/templates/pages/ticket.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title=doc.name %} diff --git a/website/templates/pages/tickets.html b/website/templates/pages/tickets.html index 11da32978d..843d10e38a 100644 --- a/website/templates/pages/tickets.html +++ b/website/templates/pages/tickets.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title="My Tickets" %} diff --git a/website/templates/pages/writers.html b/website/templates/pages/writers.html index bba374946c..67c0b7e6e1 100644 --- a/website/templates/pages/writers.html +++ b/website/templates/pages/writers.html @@ -1,4 +1,4 @@ -{% extends "html/page.html" %} +{% extends "app/website/templates/html/page.html" %} {% set title="Blog Writers" %} @@ -10,8 +10,8 @@ {% endif %}
{% for blogger_info in bloggers %} - {% include "html/blogger.html" %} + {% include "app/website/templates/html/blogger.html" %} {% endfor %}
-{% include 'html/blog_footer.html' %} +{% include 'app/website/templates/html/blog_footer.html' %} {% endblock %} \ No newline at end of file