Changeset 2034
- Timestamp:
- 06/16/09 12:23:37 (9 months ago)
- Location:
- branches/0.9/pylucid_project
- Files:
-
- 2 added
- 11 modified
-
apps/pylucid/context_processors.py (modified) (2 diffs)
-
apps/pylucid_update/views.py (modified) (2 diffs)
-
media/PyLucid/pylucid_js_tools.js (modified) (2 diffs)
-
media/PyLucid/superfish/pylucid_superfish_init.js (modified) (1 diff)
-
pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html (modified) (1 diff)
-
pylucid_plugins/auth/templates/auth/input_password.html (modified) (2 diffs)
-
pylucid_plugins/auth/templates/auth/input_username.html (modified) (3 diffs)
-
pylucid_plugins/auth/templates/auth/login_link.html (added)
-
pylucid_plugins/auth/templates/auth/logout_link.html (added)
-
pylucid_plugins/auth/views.py (modified) (7 diffs)
-
pylucid_plugins/extrahead/context_middleware.py (modified) (3 diffs)
-
pylucid_plugins/page_admin/templates/page_admin/edit_page_form.html (modified) (4 diffs)
-
pylucid_plugins/page_admin/views.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/apps/pylucid/context_processors.py
r2002 r2034 12 12 from pylucid_project import PYLUCID_VERSION_STRING 13 13 from pylucid_project.utils import slug 14 from pylucid_plugins.auth.context_processors import auth_context_processors 14 15 15 16 16 17 def _add_plugin_info(request, context): 17 """ Add css anchor into context. Used info mation from lucidTagNode. """18 """ Add css anchor into context. Used information from lucidTagNode. """ 18 19 19 20 plugin_name = request.plugin_name … … 58 59 } 59 60 60 61 62 # TODO: Use internal SHA-Login plugin views, if implemented: 63 if request.user.is_authenticated(): 64 # admin_logout reverse is still broken in django, see: 65 # http://code.djangoproject.com/ticket/11080 66 # http://code.djangoproject.com/attachment/ticket/10061 67 #url = reverse("admin_logout") 68 #url = reverse("admin_index") + "logout/" # TODO: Update this if django is bugfixed 69 url = "?auth=logout" 70 71 txt = "%s [%s]" % (_("Log out"), request.user.username) 72 else: 73 #url = reverse("admin_index") # django admin panel index page 74 url = "?auth=login" 75 txt = _("Log in") 76 77 context["login_link"] = mark_safe('<a href="%s">%s</a>' % (url, txt)) 61 # TODO: Put all Plugin context processors into settings? 62 context.update(auth_context_processors(request)) 78 63 79 64 if hasattr(request, "plugin_name"): -
branches/0.9/pylucid_project/apps/pylucid_update/views.py
r2030 r2034 267 267 content = template.content 268 268 269 new_head_file_tag = ( 269 270 SCRIPT_TAG = ( 270 271 '<script src="%(url)s"' 271 272 ' onerror="JavaScript:alert(\'Error loading file [%(url)s] !\');"' 272 273 ' type="text/javascript" /></script>\n' 273 '<!-- ContextMiddleware extrahead -->\n' 274 ) % { 274 ) 275 276 new_head_file_tag = "" 277 new_head_file_tag += SCRIPT_TAG % { 275 278 "url": posixpath.join(settings.MEDIA_URL, settings.PYLUCID.PYLUCID_MEDIA_DIR, "jquery.js") 276 279 } 280 new_head_file_tag += SCRIPT_TAG % { 281 "url": posixpath.join( 282 settings.MEDIA_URL, settings.PYLUCID.PYLUCID_MEDIA_DIR, "pylucid_js_tools.js" 283 ) 284 } 285 new_head_file_tag += '<!-- ContextMiddleware extrahead -->\n' 277 286 278 287 content = replace(content, out,"{% lucidTag page_style %}", new_head_file_tag) … … 280 289 content = replace(content, out,"{% lucidTag head_files %}", new_head_file_tag) 281 290 content = replace(content, out,"<!-- ContextMiddleware head_files -->", new_head_file_tag) 291 292 content = replace(content, out,"{{ login_link }}", "{% lucidTag auth %}") 282 293 283 294 content = replace(content, out,"{% lucidTag back_links %}", "<!-- ContextMiddleware breadcrumb -->") -
branches/0.9/pylucid_project/media/PyLucid/pylucid_js_tools.js
r2026 r2034 1 2 3 // helper function for console logging 4 // set debug to true to enable debug logging 5 function log() { 6 if (debug && window.console && window.console.log) 7 window.console.log(Array.prototype.join.call(arguments,'')); 8 }; 9 1 10 2 11 function OpenInWindow(URL) { … … 5 14 win.focus(); 6 15 } 16 17 18 19 function get_pylucid_ajax_view(url) { 20 /************************************************************************* 21 PyLucid ajax replace function 22 23 usage e.g.: 24 ---------------------------------------------------------------------- 25 $(document).ready(function(){ 26 $("#link_id").click(function(){ 27 return get_pylucid_ajax_view("{{ ajax_get_view_url }}"); 28 }); 29 }); 30 ---------------------------------------------------------------------- 31 or: 32 ---------------------------------------------------------------------- 33 <a href="{{ url }}" onclick="return get_pylucid_ajax_view('{{ ajax_url }}');">foo</a> 34 ---------------------------------------------------------------------- 35 *************************************************************************/ 36 $("#page_content").html('<h2>loading...</h2>'); 37 $("#page_content").animate({opacity: 0.3}, 500 ); 38 39 var url = encodeURI(url); 40 log("get:" + url); 41 42 var load_normal_link = true; 43 44 $.ajax({ 45 async: false, 46 type: "GET", 47 url: url, 48 dataType: "html", 49 50 success: function(form_html){ 51 log("ajax get success."); 52 $("#page_content").html(form_html); 53 $("#page_content").animate({opacity: 1}, 500 ); 54 load_normal_link = false; 55 }, 56 error: function(XMLHttpRequest){ 57 log("ajax get response error!"); 58 // Display the complete Traceback html page 59 log(XMLHttpRequest); 60 var response_text = XMLHttpRequest.responseText; 61 log("response_text: '" + response_text + "'"); 62 if (!response_text) { 63 document.write("<h1>ajax response error</h1>"); 64 } else { 65 document.write(response_text); 66 } 67 load_normal_link = true; 68 } 69 }); 70 if (debug) { 71 // never fall back in debug mode. 72 log("return: " + load_normal_link); 73 return false; 74 } else { 75 // fall back to normal view, if ajax request failed. 76 return load_normal_link; // The browser follow the link, if true 77 } 78 } -
branches/0.9/pylucid_project/media/PyLucid/superfish/pylucid_superfish_init.js
r2022 r2034 6 6 delay: 1000, // one second delay on mouseout 7 7 animation: {opacity:'show',height:'show'}, // fade-in and slide-down animation 8 speed: 'fast' ,// faster animation speed8 speed: 'fast' // faster animation speed 9 9 }); 10 10 }); -
branches/0.9/pylucid_project/pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html
r2029 r2034 21 21 --> 22 22 </style> 23 <script type="text/javascript">24 $(document).ready(function(){25 $("#edit_page").click(function() {26 var url = encodeURI("{{ edit_page_ajax}}");27 console.log("get:" + url);28 29 bodyContent = $.ajax({30 type: "GET",31 url: url,32 dataType: "html",33 34 success: function(form_html){35 $("#page_content").html(form_html);36 },37 error: function(XMLHttpRequest){38 // Display the complete Traceback html page39 document.write(XMLHttpRequest.responseText);40 },41 });42 return false; // The browser follow the link, if true43 });44 });45 </script>46 23 {% endextrahead %} 47 24 48 25 <ul class="sf-menu"> 49 <li class="current"> 50 <a href="{{ logout_link }}">{% trans 'logout' %} [{{ request.user.username }}]</a> 51 </li> 26 <li class="current">{% lucidTag auth %}</li> 52 27 <li> 53 <li><a href=" #{{ edit_page_link }}" title="edit inline" id="edit_page">{% trans 'edit page' %}</a></li>28 <li><a href="{{ edit_page_link }}" title="edit inline" id="edit_page" onclick="return get_pylucid_ajax_view('{{ edit_page_ajax}}');">{% trans 'edit page' %}</a></li> 54 29 <ul> 55 30 <li><a href="{{ edit_admin_panel_link }}">edit in admin panel</a></li> -
branches/0.9/pylucid_project/pylucid_plugins/auth/templates/auth/input_password.html
r2022 r2034 4 4 {% block plugin_content %} 5 5 6 { % extrahead %}6 {# We can't use extrahead block here, because it's used in ajax view, too. #} 7 7 <script type="text/javascript" src="{{ PyLucid_media_url }}sha.js"></script> 8 8 <script type="text/javascript" src="{{ PyLucid_media_url }}shared_sha_tools.js"></script> … … 33 33 start_init(); 34 34 </script> 35 {% endextrahead %}36 35 37 36 <fieldset><legend>PyLucid <a href="http://www.pylucid.org/_goto/8/JS-SHA-Login/" title="What is the PyLucid JS-SHA-LogIn?">JS-SHA-LogIn</a> - step 2</legend> -
branches/0.9/pylucid_project/pylucid_plugins/auth/templates/auth/input_username.html
r2001 r2034 2 2 3 3 {% block plugin_content %} 4 <div class="{{ CSS_PLUGIN_CLASS_NAME }} {{ css_plugin_class }}" id="{{ css_plugin_id }}"> 4 {# We can't use extrahead block here, because it's used in ajax view, too. #} 5 <script type="text/javascript"> 6 7 $(document).ready(function(){ 8 log("input username ready"); 9 $("#id_username").focus(); 10 11 $('#username_form').bind('submit', function() { 12 // get the input password form via ajax 13 $("#page_content").html('<h2>loading...</h2>'); 14 $("#page_content").animate({opacity: 0.3}, 500 ); 15 16 log("continue login..."); 17 18 var form = $(this); 19 var form_data = form.serialize(); 20 log("form data:" + form_data); 21 22 var url = encodeURI(form.attr('action')); 23 log("form url:" + url); 24 25 $.post(url, form_data, 26 function(form_html){ 27 log("ajax get success."); 28 $("#page_content").html(form_html); 29 $("#page_content").animate({opacity: 1}, 500 ); 30 } 31 ); 32 33 return false; // <-- important! 34 }); 35 }); 36 </script> 37 5 38 <fieldset><legend>PyLucid <a href="http://www.pylucid.org/_goto/8/JS-SHA-Login/" title="What is the PyLucid JS-SHA-LogIn?">JS-SHA-LogIn</a> - step 1</legend> 6 39 … … 12 45 </noscript> 13 46 14 <form method="post" action="{{ form_url }}">47 <form id="username_form" method="post" action="{{ form_url }}"> 15 48 {{ form.as_p }} 16 49 <br /> … … 21 54 </form> 22 55 </fieldset> 23 24 <script type="text/javascript">document.getElementById("id_username").focus();</script>25 </div>26 56 {% endblock %} -
branches/0.9/pylucid_project/pylucid_plugins/auth/views.py
r2022 r2034 25 25 26 26 27 def lucidTag(request): 28 # TODO: Use internal SHA-Login plugin views, if implemented: 29 if request.user.is_authenticated(): 30 # admin_logout reverse is still broken in django, see: 31 # http://code.djangoproject.com/ticket/11080 32 # http://code.djangoproject.com/attachment/ticket/10061 33 #url = reverse("admin_logout") 34 #url = reverse("admin_index") + "logout/" # TODO: Update this if django is bugfixed 35 template_name = "auth/logout_link.html" 36 context = {"logout_url": "?auth=logout"} 37 else: 38 template_name = "auth/login_link.html" 39 #url = reverse("admin_index") # django admin panel index page 40 context = { 41 "login_url": "?auth=login", 42 "login_url_ajax": "?auth=get_login_form", 43 } 44 45 return render_to_string(template_name, context, context_instance=RequestContext(request)) 46 47 48 49 27 50 def _logout_view(request, next_url): 28 51 """ Logout the current user. """ … … 43 66 44 67 45 def _plaintext_login(request, context, username, next_url ):68 def _plaintext_login(request, context, username, next_url, render_function): 46 69 """ input the password and login if auth ok """ 47 70 if "password" in request.POST: … … 56 79 57 80 # return a string for replacing the normal cms page content 58 return render_ to_string('auth/plaintext_login.html', context)59 60 61 62 def _sha_login(request, context, user, next_url ):81 return render_function('auth/plaintext_login.html', context) 82 83 84 85 def _sha_login(request, context, user, next_url, render_function): 63 86 """ 64 87 Login via JS-SHA-Login. … … 122 145 123 146 # return a string for replacing the normal cms page content 124 return render_to_string('auth/input_password.html', context, 125 context_instance=RequestContext(request) 126 ) 127 128 129 def _login_view(request, form_url, next_url): 147 return render_function('auth/input_password.html', context, context_instance=RequestContext(request)) 148 149 150 def _login_view(request, form_url, next_url, render_function): 130 151 if DEBUG: 131 152 request.page_msg( … … 147 168 148 169 if "plaintext_login" in request.POST: 149 return _plaintext_login(request, context, user.username, next_url )170 return _plaintext_login(request, context, user.username, next_url, render_function) 150 171 else: 151 return _sha_login(request, context, user, next_url )172 return _sha_login(request, context, user, next_url, render_function) 152 173 else: 153 174 username_form = UsernameForm() … … 156 177 157 178 # return a string for replacing the normal cms page content 158 return render_ to_string('auth/input_username.html', context)179 return render_function('auth/input_username.html', context) 159 180 160 181 … … 164 185 """ 165 186 next_url = request.path 166 187 # import time 188 # time.sleep(0.5) 167 189 action = request.GET["auth"] 168 190 if action=="login": 169 191 form_url = request.path + "?auth=login" # FIXME: How can we add the GET Parameter? 170 return _login_view(request, form_url, next_url) 192 return _login_view(request, form_url, next_url, render_function=render_to_string) 193 elif action=="get_login_form": 194 form_url = request.path + "?auth=get_login_form" # FIXME: How can we add the GET Parameter? 195 return _login_view(request, form_url, next_url, render_function=render_to_response) 171 196 elif action=="logout": 172 197 return _logout_view(request, next_url) -
branches/0.9/pylucid_project/pylucid_plugins/extrahead/context_middleware.py
r2022 r2034 49 49 def __init__(self, request, context): 50 50 self.request = request 51 self.data = "" 51 if settings.DEBUG: 52 # Turn debug mode in JavaScript on 53 self.data = DEBUG_INFO % { 54 "fileinfo": os.path.basename(__file__), 55 "content": '<script type="text/javascript">var debug=true;log("debug is on");</script>' 56 } 57 self.data += "\n" 58 else: 59 self.data = "" 52 60 53 61 def add_content(self, content): … … 89 97 return False 90 98 91 def cut(filepath): 92 return "..." + filepath.split(FILEPATH_SPLIT,1)[1] 93 if len(filepath)>=MAX_FILEPATH_LEN: 94 return "...%s" % filepath[-MAX_FILEPATH_LEN:] 95 return filepath 96 97 98 try: 99 self_basename = os.path.basename(__file__) 100 if self_basename.endswith(".pyc"): 101 # cut: ".pyc" -> ".py" 102 self_basename = self_basename[:-1] 103 99 try: 104 100 fileinfo = [] 105 101 step = 0 … … 111 107 continue 112 108 113 fileinfo.append("%s line %s" % (cut(filepath), lineno)) 109 filepath = "..." + filepath.split(FILEPATH_SPLIT,1)[1] 110 111 fileinfo.append("%s line %s" % (filepath, lineno)) 114 112 if step>=1: 115 113 break -
branches/0.9/pylucid_project/pylucid_plugins/page_admin/templates/page_admin/edit_page_form.html
r2029 r2034 1 {% extends "pylucid/css_anchor_div.html" %} 2 3 {% block plugin_content %} 4 5 {# We can't use extrahead block here, because it's used in ajax view, too. #} 1 6 <script type="text/javascript"> 2 7 $(document).ready(function(){ 3 8 $("#preview_fieldset").hide(); 4 $("#preview").click(function() { 9 10 $("#preview").click(function() { 11 $("#edit_page_preview").html("<h2>loading...</h2>"); 12 $("#preview_fieldset").slideDown(); 13 5 14 var content = $("#id_content")[0].value; 6 15 … … 11 20 $.post(url, { 'content': content }, function(form_html){ 12 21 $("#edit_page_preview").html(form_html); 13 $("#preview_fieldset").slideDown();22 14 23 }); 15 24 return false; // The browser submit the form, if true … … 43 52 {% endif %} 44 53 45 <a href="{{ url_pagelinklist}}" title="{% trans 'List of all pages for creating links' %}">46 <button type="button" onclick="OpenInWindow('{{ url_pagelinklist}}'); return false">54 <a href="{{ pagelinklist_url }}" title="{% trans 'List of all pages for creating links' %}"> 55 <button type="button" onclick="OpenInWindow('{{ pagelinklist_url }}'); return false"> 47 56 {% trans 'page list' %} 48 57 </button> 49 58 </a> 50 <a href="{{ url_taglist}}" title="{% trans 'List of all available PyLucid template tags' %}">51 <button type="button" onclick="OpenInWindow('{{ url_taglist}}'); return false">59 <a href="{{ taglist_url }}" title="{% trans 'List of all available PyLucid template tags' %}"> 60 <button type="button" onclick="OpenInWindow('{{ taglist_url }}'); return false"> 52 61 {% trans 'tag list' %} 53 62 </button> … … 78 87 </form> 79 88 </fieldset> 89 {% endblock %} -
branches/0.9/pylucid_project/pylucid_plugins/page_admin/views.py
r2029 r2034 56 56 "abort_url": request.path, 57 57 "preview_url": "%s?page_admin=preview" % request.path, 58 59 "pagelinklist_url": "#TODO", #FIXME ;) 60 "taglist_url": "#TODO", #FIXME ;) 61 58 62 "edit_page_form": edit_page_form, 59 63 "pagecontent_instance": pagecontent_instance,