From 158d6b3d283cabf6467f2b9682479bfe9c482da7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 3 Apr 2013 16:36:53 +0530 Subject: [PATCH] [website] [cleanup] added website pages to framework --- config.json | 31 +++++++++--- templates/base.html | 25 ++++++++++ templates/css/login.css | 43 ++++++++++++++++ templates/js/login.js | 97 ++++++++++++++++++++++++++++++++++++ templates/pages/404.html | 14 ++++++ templates/pages/error.html | 13 +++++ templates/pages/login.html | 62 +++++++++++++++++++++++ templates/pages/message.html | 11 ++++ templates/pages/print.html | 18 +++++++ webnotes/__init__.py | 25 ++++++---- webnotes/webutils.py | 54 +++++++++++++------- 11 files changed, 359 insertions(+), 34 deletions(-) create mode 100644 templates/base.html create mode 100644 templates/css/login.css create mode 100644 templates/js/login.js create mode 100644 templates/pages/404.html create mode 100644 templates/pages/error.html create mode 100644 templates/pages/login.html create mode 100644 templates/pages/message.html create mode 100644 templates/pages/print.html diff --git a/config.json b/config.json index ffc6d2cc13..cee89611ae 100644 --- a/config.json +++ b/config.json @@ -1,12 +1,5 @@ { "modules": { - "Activity": { - "type": "page", - "link": "activity", - "color": "#633501", - "icon": "icon-play", - "label": "Activity" - }, "To Do": { "type": "page", "link": "todo", @@ -28,5 +21,29 @@ "label": "Messages", "icon": "icon-comments" } + }, + "web": { + "pages": { + "404": { + "template": "lib/templates/pages/404" + }, + "error": { + "no_cache": true, + "template": "lib/templates/pages/error" + }, + "login": { + "template": "lib/templates/pages/login" + }, + "message": { + "no_cache": true, + "template": "lib/templates/pages/message" + }, + "print": { + "no_cache": true, + "template": "lib/templates/pages/print", + "args_method": "core.doctype.print_format.print_format.get_args" + } + }, + "generators": {} } } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000000..cfba1a5ca0 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,25 @@ + + + + + + {{ title }} + + + + + + + + + {% if description -%} + + {%- endif %} + {% block header -%} + {%- endblock %} + + + {% block body %} + {% endblock %} + + \ No newline at end of file diff --git a/templates/css/login.css b/templates/css/login.css new file mode 100644 index 0000000000..4120807022 --- /dev/null +++ b/templates/css/login.css @@ -0,0 +1,43 @@ + \ No newline at end of file diff --git a/templates/js/login.js b/templates/js/login.js new file mode 100644 index 0000000000..06ea4c5242 --- /dev/null +++ b/templates/js/login.js @@ -0,0 +1,97 @@ + +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/templates/pages/404.html b/templates/pages/404.html new file mode 100644 index 0000000000..3c37a30f38 --- /dev/null +++ b/templates/pages/404.html @@ -0,0 +1,14 @@ +{% extends "app/website/templates/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/templates/pages/error.html b/templates/pages/error.html new file mode 100644 index 0000000000..5ebe552bbc --- /dev/null +++ b/templates/pages/error.html @@ -0,0 +1,13 @@ +{% extends "lib/templates/base.html" %} + +{% set title="Error" %} + +{% block body %} +
+
+

Oops, a server error has occured

+
+
%(error)s
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/pages/login.html b/templates/pages/login.html new file mode 100644 index 0000000000..285094b893 --- /dev/null +++ b/templates/pages/login.html @@ -0,0 +1,62 @@ +{% extends "lib/templates/base.html" %} + +{% block header %} + + {% include "lib/templates/css/login.css" %} +{% endblock %} + +{% set title="Login" %} + +{% block body %} +
+
+ +

Login

+
+ + + + + + + + + + + + + + + + + + + + +
+
+

+ Forgot Password

+

+ New user? Sign Up

+
+
+