[website] [cleanup] separated website generation in framework and erpnext

This commit is contained in:
Rushabh Mehta 2013-04-03 16:34:23 +05:30
parent 27c4079ff9
commit 3023a8fa9b
32 changed files with 114 additions and 369 deletions

View File

@ -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"
}
}
}
}

View File

@ -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:

View File

@ -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)

View File

@ -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):

View File

@ -1,43 +0,0 @@
<style>
#login_wrapper {
width: 300px;
margin: 70px auto;
}
#login_wrapper,
#login_wrapper h3 {
color: #333;
}
#login_wrapper a {
color: #0088cc;
}
.layout-wrapper {
background-color: #fff;
padding: 10px;
box-shadow: 1px 1px 3px 3px #ccc;
font-size: 12px;
min-height: 100px;
border-radius: 5px;
}
#login_wrapper h3 {
text-align: center;
}
.login-banner {
margin-bottom: 20px;
}
.login-box td {
padding: 8px;
}
.login-box td input {
margin-bottom: 0px;
}
.login-footer {
text-align: center;
padding: 15px;
}
</style>

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title>
<meta name="generator" content="wnframework">
<script type="text/javascript" src="lib/js/lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="js/all-web.min.js"></script>
<script type="text/javascript" src="js/wn-web.js"></script>
<link type="text/css" rel="stylesheet" href="css/all-web.css">
<link type="text/css" rel="stylesheet" href="css/wn-web.css">
<link rel="shortcut icon" href="{{ favicon }}" type="image/x-icon">
<link rel="icon" href="{{ favicon }}" type="image/x-icon">
{% if description -%}
<meta name="description" content="{{ description }}">
{%- endif %}
{% block header -%}
{%- endblock %}
</head>
<body>
{% block body %}
{% endblock %}
</body>
</html>

View File

@ -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 @@
<!-- end blog content -->
{% if blogger_info %}
<hr />
{% include "html/blogger.html" %}
{% include "app/website/templates/html/blogger.html" %}
{% endif %}
<hr>
<h3>{{ texts.comments }}</h3><br>
@ -35,7 +35,7 @@
</div>
{% endif %}
{% include 'html/comment.html' %}
{% include 'app/website/templates/html/comment.html' %}
</div>
<div><button class="btn add-comment">{{ texts.add_comment }}</button></div>
<div style="display: none; margin-top: 10px;"
@ -52,5 +52,5 @@
</form>
</div>
</div>
{% include 'html/blog_footer.html' %}
{% include 'app/website/templates/html/blog_footer.html' %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "html/base.html" %}
{% extends "lib/templates/base.html" %}
{% block body %}
<div class="container">
@ -10,13 +10,13 @@
<div class="span12">{{ banner_html }}</div>
</div>{% endif %}
<div class="outer">
{% include "html/navbar.html" %}
{% include "app/website/templates/html/navbar.html" %}
<div class="content row" id="page-{{ name }}" style="display: block;">
{%- block content -%}
{%- endblock -%}
</div>
</div>
</div>
{% include "html/footer.html" %}
{% include "app/website/templates/html/footer.html" %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "html/outer.html" %}
{% extends "app/website/templates/html/outer.html" %}
{% block title -%}{{ title }}{%- endblock %}

View File

@ -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' %}
<div class="span12">
{% if slideshow %}<!-- slideshow -->
{% include "html/slideshow.html" %}
{% include "app/website/templates/html/slideshow.html" %}
{% endif %}
{% if description %}<!-- description -->
<div>{{ description or ""}}</div>

View File

@ -4,7 +4,7 @@
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}
{% include 'html/product_missing_image.html' %}
{% include 'app/website/templates/html/product_missing_image.html' %}
{%- endif -%}
</a>
</div>

View File

@ -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' %}
<div class="span12 product-page-content" itemscope itemtype="http://schema.org/Product">
<div class="row">
<div class="span6">
{% if slideshow %}
{% include "html/slideshow.html" %}
{% include "app/website/templates/html/slideshow.html" %}
{% else %}
{% if website_image %}
<image itemprop="image" class="item-main-image"
src="{{ website_image }}" />
{% else %}
<div class="img-area">
{% include 'html/product_missing_image.html' %}
{% include 'app/website/templates/html/product_missing_image.html' %}
</div>
{% endif %}
{% endif %}

View File

@ -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 %}
<div class="span12" style="margin-top: 15px;">
{% include "html/slideshow.html" %}
{% include "app/website/templates/html/slideshow.html" %}
{{ main_section }}
</div>
{% endblock %}

View File

@ -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("<a onclick='location.reload()' href='#'>Login</a>")
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("<a onclick='location.reload()' href='#'>Login</a>")
window.is_forgot = true;
}
login.set_message = function(message, color) {
$('#login_message').html(message).toggle(true);
}

View File

@ -1,14 +0,0 @@
{% extends "html/outer.html" %}
{% set title="Not Found" %}
{% block content %}
<div class="content">
<div class="layout-wrapper layout-main">
<h3><i class="icon-exclamation-sign"></i> Page missing or moved</h3>
<br>
<p>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.</p>
</div>
</div>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title="About Us" %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title="My Account" %}

View File

@ -1,4 +1,4 @@
{% extends "html/outer.html" %}
{% extends "app/website/templates/html/outer.html" %}
{% block header %}
<style>

View File

@ -1,11 +1,11 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% block javascript %}
{% include "js/blog.js" %}
{% include "app/website/templates/js/blog.js" %}
{% endblock %}
{% block css %}
{% include "css/blog.css" %}
{% include "app/website/templates/css/blog.css" %}
{% endblock %}
{% set title="Blog" %}
@ -29,5 +29,5 @@
style="display:none;">More...</button>
</div>
</div>
{% include 'html/blog_footer.html' %}
{% include 'app/website/templates/html/blog_footer.html' %}
{% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% block javascript %}
{% include "js/contact.js" %}
{% include "app/website/templates/js/contact.js" %}
{% endblock %}
{% set title="Contact Us" %}

View File

@ -1,13 +0,0 @@
{% extends "html/outer.html" %}
{% set title="Error" %}
{% block content %}
<div class="content">
<div class="layout-wrapper layout-main">
<h3><i class="icon-exclamation-sign"></i> Oops, a server error has occured</h3>
<br>
<pre>%(error)s</pre>
</div>
</div>
{% endblock %}

View File

@ -1 +1 @@
{% extends "html/web_page.html" %}
{% extends "app/website/templates/html/web_page.html" %}

View File

@ -1,62 +0,0 @@
{% extends "html/base.html" %}
{% block header %}
<script>
{% include "js/login.js" %}
</script>
{% include "css/login.css" %}
{% endblock %}
{% set title="Login" %}
{% block body %}
<div class="container" id='login_wrapper'>
<div class='layout-wrapper layout-main'>
<p id="login_message" class="alert" style="display: none;"></p>
<h3><i class="icon-lock" style="margin-top: 7px"></i> Login</h3>
<form autocomplete="on">
<table border="0" class="login-box">
<tbody>
<tr>
<td style="text-align: right; padding: 3px;"
id="login-label">Login Id</td>
<td><input id="login_id" type="text" style="width: 180px"/></td>
</tr>
<tr id="password-row">
<td style="text-align: right; padding: 3px;" >Password</td>
<td><input id="password" type="password" style="width: 180px" /></td>
</tr>
<tr id="full-name-row" style="display: none;">
<td style="text-align: right; padding: 3px;">Full Name</td>
<td><input id="full_name" type="text" style="width: 180px" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<button type="submit" id="login_btn"
class="btn btn-small btn-primary">Login</button>
<img src="lib/images/ui/button-load.gif" id="login-spinner"
style="display: none;">
</td>
</tr>
</tbody>
</table>
</form>
<br>
<p style="text-align: center" id="forgot-wrapper">
<a id="forgot-password" style="cursor:pointer"
onclick="return login.show_forgot_password()">Forgot Password</a></p>
<p style="text-align: center" id="sign-up-wrapper">
New user? <a id="sign-up" style="cursor:pointer"
onclick="return login.sign_up()">Sign Up</a></p>
</div>
</div>
<div class="web-footer login-footer container">
<a href="index.html">Home</a> |
<a href="https://erpnext.com">ERPNext</a><br><br>
{% if copyright %}
<div class="web-footer-copyright">&copy; {{ copyright }}
{% endif %}
</div>
{% endblock %}

View File

@ -1,11 +0,0 @@
{% extends "html/outer.html" %}
{% set title=webnotes.message_title %}
{% block content %}
<div class="content">
<div class="layout-wrapper layout-main">
{{ webnotes.message }}
</div>
</div>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title=doc.name %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title="My Orders" %}

View File

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Print Format</title>
<meta name="generator" content="wnframework">
<style>
{{ css }}
</style>
</head>
<body>
{{ body }}
</body>
{%- if comment -%}
<!-- {{ comment }} -->
{%- endif -%}
</html>

View File

@ -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() {
});
</script>
{% include 'html/product_search_box.html' %}
{% include 'app/website/templates/html/product_search_box.html' %}
<div class="span12">
<h3 class="search-results">Search Results</h3>
<div id="search-list" class="row">

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title="My Profile" %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title=doc.name %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title="My Tickets" %}

View File

@ -1,4 +1,4 @@
{% extends "html/page.html" %}
{% extends "app/website/templates/html/page.html" %}
{% set title="Blog Writers" %}
@ -10,8 +10,8 @@
{% endif %}
<hr>
{% for blogger_info in bloggers %}
{% include "html/blogger.html" %}
{% include "app/website/templates/html/blogger.html" %}
{% endfor %}
</div>
{% include 'html/blog_footer.html' %}
{% include 'app/website/templates/html/blog_footer.html' %}
{% endblock %}