##// END OF EJS Templates
Merge branch 'logout_button' of https://github.com/stefanv/ipython into stefanv-logout_button...
Fernando Perez -
r5359:80e7338b merge
parent child Browse files
Show More
@@ -0,0 +1,77 b''
1 <!DOCTYPE HTML>
2 <html>
3
4 <head>
5 <meta charset="utf-8">
6
7 <title>{% block title %}IPython Notebook{% end %}</title>
8
9 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
10 <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" />
11 <link rel="stylesheet" href="static/css/layout.css" type="text/css" />
12 <link rel="stylesheet" href="static/css/base.css" type="text/css"/>
13 {% block stylesheet %}
14 {% end %}
15
16 {% block meta %}
17 {% end %}
18
19 </head>
20
21 <body {% block params %}{% end %}>
22
23 <div id="header">
24 <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
25 <span id="login_widget">
26 {% if current_user and current_user != 'anonymous' %}
27 <button id="logout">Logout</button>
28 {% end %}
29 </span>
30 {% block header %}
31 {% end %}
32 </div>
33
34 <div id="header_border"></div>
35
36 <div id="main_app">
37
38 <div id="app_hbox">
39
40 <div id="left_panel">
41 {% block left_panel %}
42 {% end %}
43 </div>
44
45 <div id="content_panel">
46 {% if message %}
47
48 {% for key in message %}
49 <div class="message {{key}}">
50 {{message[key]}}
51 </div>
52 {% end %}
53 {% end %}
54
55 {% block content_panel %}
56 {% end %}
57 </div>
58 <div id="right_panel">
59 {% block right_panel %}
60 {% end %}
61 </div>
62
63 </div>
64
65 </div>
66
67 <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
68 <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
69 <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
70 <script src="static/js/loginmain.js" type="text/javascript" charset="utf-8"></script>
71 <script src="static/js/loginwidget.js" type="text/javascript" charset="utf-8"></script>
72 {% block script %}
73 {% end %}
74
75 </body>
76
77 </html>
@@ -0,0 +1,5 b''
1 {% extends layout.html %}
2
3 {% block content_panel %}
4 Proceed to the <a href="/login">login page</a>.
5 {% end %}
@@ -116,7 +116,14 b' def authenticate_unless_readonly(f, self, *args, **kwargs):'
116 116 # Top-level handlers
117 117 #-----------------------------------------------------------------------------
118 118
119 class AuthenticatedHandler(web.RequestHandler):
119 class RequestHandler(web.RequestHandler):
120 """RequestHandler with default variable setting."""
121
122 def render(*args, **kwargs):
123 kwargs.setdefault('message', '')
124 return web.RequestHandler.render(*args, **kwargs)
125
126 class AuthenticatedHandler(RequestHandler):
120 127 """A RequestHandler with an authenticated user."""
121 128
122 129 def get_current_user(self):
@@ -167,7 +174,7 b' class ProjectDashboardHandler(AuthenticatedHandler):'
167 174
168 175 class LoginHandler(AuthenticatedHandler):
169 176
170 def _render(self, message=''):
177 def _render(self, message=None):
171 178 self.render('login.html',
172 179 next=self.get_argument('next', default='/'),
173 180 read_only=self.read_only,
@@ -175,7 +182,10 b' class LoginHandler(AuthenticatedHandler):'
175 182 )
176 183
177 184 def get(self):
178 self._render()
185 if self.current_user:
186 self.redirect(self.get_argument('next', default='/'))
187 else:
188 self._render()
179 189
180 190 def post(self):
181 191 pwd = self.get_argument('password', default=u'')
@@ -183,12 +193,19 b' class LoginHandler(AuthenticatedHandler):'
183 193 if passwd_check(self.application.password, pwd):
184 194 self.set_secure_cookie('username', str(uuid.uuid4()))
185 195 else:
186 self._render(message='Invalid password')
196 self._render(message={'error': 'Invalid password'})
187 197 return
188 198
189 199 self.redirect(self.get_argument('next', default='/'))
190 200
191 201
202 class LogoutHandler(AuthenticatedHandler):
203
204 def get(self):
205 self.clear_cookie('username')
206 self.render('logout.html', message={'info': 'Successfully logged out.'})
207
208
192 209 class NewHandler(AuthenticatedHandler):
193 210
194 211 @web.authenticated
@@ -40,7 +40,7 b' from tornado import web'
40 40
41 41 # Our own libraries
42 42 from .kernelmanager import MappingKernelManager
43 from .handlers import (LoginHandler,
43 from .handlers import (LoginHandler, LogoutHandler,
44 44 ProjectDashboardHandler, NewHandler, NamedNotebookHandler,
45 45 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
46 46 ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler
@@ -87,6 +87,7 b' class NotebookWebApplication(web.Application):'
87 87 handlers = [
88 88 (r"/", ProjectDashboardHandler),
89 89 (r"/login", LoginHandler),
90 (r"/logout", LogoutHandler),
90 91 (r"/new", NewHandler),
91 92 (r"/%s" % _notebook_id_regex, NamedNotebookHandler),
92 93 (r"/kernels", MainKernelHandler),
@@ -102,12 +102,27 b''
102 102 box-pack: center;
103 103 }
104 104
105 #message {
106 border: 1px solid red;
107 background-color: #FFD3D1;
105 .message {
106 border-width: 1px;
107 border-style: solid;
108 108 text-align: center;
109 109 padding: 0.5em;
110 margin: 0.5em;
110 margin: 0.5em 0;
111 }
112
113 .message.error {
114 background-color: #FFD3D1;
115 border-color: red;
116 }
117
118 .message.warning {
119 background-color: #FFD09E;
120 border-color: orange;
121 }
122
123 .message.info {
124 background-color: #CBFFBA;
125 border-color: green;
111 126 }
112 127
113 128 #content_panel {
@@ -21,12 +21,12 b' var IPython = (function (IPython) {'
21 21 };
22 22
23 23 LoginWidget.prototype.style = function () {
24 this.element.find('button#login').button();
24 this.element.find('button#logout').button();
25 25 };
26 26 LoginWidget.prototype.bind_events = function () {
27 27 var that = this;
28 this.element.find("button#login").click(function () {
29 window.location = "/login?next="+location.pathname;
28 this.element.find("button#logout").click(function () {
29 window.location = "/logout";
30 30 });
31 31 };
32 32
@@ -1,61 +1,8 b''
1 <!DOCTYPE HTML>
2 <html>
3
4 <head>
5 <meta charset="utf-8">
6
7 <title>IPython Notebook</title>
8
9 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
10 <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" />
11 <link rel="stylesheet" href="static/css/layout.css" type="text/css" />
12 <link rel="stylesheet" href="static/css/base.css" type="text/css" />
13
14 <meta name="read_only" content="{{read_only}}"/>
15
16 </head>
17
18 <body>
19
20 <div id="header">
21 <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
22 </div>
23
24 <div id="header_border"></div>
25
26 <div id="main_app">
27
28 <div id="app_hbox">
29
30 <div id="left_panel">
31 </div>
32
33 <div id="content_panel">
34 {% if message %}
35 <div id="message">
36 {{message}}
37 </div>
38 {% end %}
39
40 <form action="/login?next={{url_escape(next)}}" method="post">
41 Password: <input type="password" name="password">
42 <input type="submit" value="Sign in" id="signin">
43 </form>
44 </div>
45 <div id="right_panel">
46 </div>
47
48 </div>
49
50 </div>
51
52 <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
53 <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
54 <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
55 <script src="static/js/loginmain.js" type="text/javascript" charset="utf-8"></script>
56
57 </body>
58
59 </html>
60
61
1 {% extends layout.html %}
2
3 {% block content_panel %}
4 <form action="/login?next={{url_escape(next)}}" method="post">
5 Password: <input type="password" name="password">
6 <input type="submit" value="Sign in" id="signin">
7 </form>
8 {% end %}
@@ -59,9 +59,15 b''
59 59 <span id="quick_help_area">
60 60 <button id="quick_help">Quick<u>H</u>elp</button>
61 61 </span>
62 <span id="login_widget" class="hidden">
63 <button id="login">Login</button>
62
63 <span id="login_widget">
64 {% comment This is a temporary workaround to hide the logout button %}
65 {% comment when appropriate until notebook.html is templated %}
66 {% if current_user and current_user != 'anonymous' %}
67 <button id="logout">Logout</button>
68 {% end %}
64 69 </span>
70
65 71 <span id="kernel_status">Idle</span>
66 72 </div>
67 73
@@ -1,69 +1,36 b''
1 <!DOCTYPE HTML>
2 <html>
1 {% extends layout.html %}
3 2
4 <head>
5 <meta charset="utf-8">
3 {% block title %}
4 IPython Dashboard
5 {% end %}
6 6
7 <title>IPython Dashboard</title>
8
9 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
10 <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" />
11 <link rel="stylesheet" href="static/css/layout.css" type="text/css" />
12 <link rel="stylesheet" href="static/css/base.css" type="text/css" />
7 {% block stylesheet %}
13 8 <link rel="stylesheet" href="static/css/projectdashboard.css" type="text/css" />
9 {% end %}
14 10
11 {% block meta %}
15 12 <meta name="read_only" content="{{read_only}}"/>
16
17 </head>
18
19 <body data-project={{project}} data-base-project-url={{base_project_url}}
20 data-base-kernel-url={{base_kernel_url}}>
21
22 <div id="header">
23 <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
24 <span id="login_widget" class="hidden">
25 <button id="login">Login</button>
26 </span>
27 </div>
28
29 <div id="header_border"></div>
30
31 <div id="main_app">
32
33 <div id="app_hbox">
34
35 <div id="left_panel">
36 </div>
37
38 <div id="content_panel">
39 <div id="content_toolbar">
40 <span id="drag_info">Drag files onto the list to import notebooks.</span>
41 <span id="notebooks_buttons">
42 <button id="new_notebook">New Notebook</button>
43 </span>
44 </div>
45 <div id="notebook_list">
46 <div id="project_name"><h2>{{project}}</h2></div>
47 </div>
48
13 {% end %}
14
15 {% block params %}
16 data-project={{project}}
17 data-base-project-url={{base_project_url}}
18 data-base-kernel-url={{base_kernel_url}}
19 {% end %}
20
21 {% block content_panel %}
22 <div id="content_toolbar">
23 <span id="drag_info">Drag files onto the list to import notebooks.</span>
24 <span id="notebooks_buttons">
25 <button id="new_notebook">New Notebook</button>
26 </span>
49 27 </div>
50
51 <div id="right_panel">
28 <div id="notebook_list">
29 <div id="project_name"><h2>{{project}}</h2></div>
52 30 </div>
53
54 </div>
55
56 </div>
57
58 <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
59 <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
60 <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
61 <script src="static/js/notebooklist.js" type="text/javascript" charset="utf-8"></script>
62 <script src="static/js/loginwidget.js" type="text/javascript" charset="utf-8"></script>
63 <script src="static/js/projectdashboardmain.js" type="text/javascript" charset="utf-8"></script>
64
65 </body>
66
67 </html>
68
31 {% end %}
69 32
33 {% block script %}
34 <script src="static/js/notebooklist.js" type="text/javascript" charset="utf-8"></script>
35 <script src="static/js/projectdashboardmain.js" type="text/javascript" charset="utf-8"></script>
36 {% end %}
General Comments 0
You need to be logged in to leave comments. Login now