On Fri, 2006-01-20 at 00:21 +1100, Assaph Mehr wrote:
> Am not aware of any such work but it should not be hard to hack: All
> you need it to set the cookie at the login page, and retrieve it in
> the #save action (and remove the textfield for author name from the
> view of course).
> 
> Let us know if you need more info... and patches are always welcome :-)

This is not very general purpose, I'm afraid, but it does the job for
us.

The one thing I didn't understand was this 'default="yes"' business in
the password field in login.rhtml.  I couldn't find any doc on that
attribute.  Something to do with being able to press enter in a
textfield to submit the form?  But now that we have two text fields, I
think we need a submit button of some sort, so I added one.

Ben

Index: instiki/app/controllers/application.rb
===================================================================
--- instiki/app/controllers/application.rb	(revision 12190)
+++ instiki/app/controllers/application.rb	(working copy)
@@ -47,6 +47,7 @@
     end
     @page_name = @file_name = @params['id']
     @page = @wiki.read_page(@web_name, @page_name) unless @page_name.nil?
+    cookies['author'] = @params['author'] if @params['author']
     @author = cookies['author'] || 'AnonymousCoward'
     check_authorization
   end
Index: instiki/app/views/wiki/login.rhtml
===================================================================
--- instiki/app/views/wiki/login.rhtml	(revision 12190)
+++ instiki/app/views/wiki/login.rhtml	(working copy)
@@ -4,11 +4,14 @@
 <%= form_tag({ :controller => 'wiki', :action => 'authenticate', :web => @web.address},
     { 'name' => 'loginForm', 'id' => 'loginForm', 'method' => 'post'})
 %>
+    <b>Username</b><br />
+    <input type="author" name="author" id="author" /><br />
     <b>Password</b><br />
-    <input type="password" name="password" id="password" default="yes" />
+    <input type="password" name="password" id="password" /><br />
+    <input type="submit" name="login" id="login" value="Login" default="yes" />
 <%= end_form_tag %>
 </p>
 
 <script language="JavaScript">
-  document.forms["loginForm"].elements["password"].focus();
+  document.forms["loginForm"].elements["author"].focus();
 </script>
Index: instiki/app/views/wiki/edit.rhtml
===================================================================
--- instiki/app/views/wiki/edit.rhtml	(revision 12190)
+++ instiki/app/views/wiki/edit.rhtml	(working copy)
@@ -17,9 +17,8 @@
     <textarea name="content" style="width: 450px; height: 500px"><%= h(@flash[:content] || @page.content) %></textarea>
 </p>
 <p>
-    <input type="submit" value="Submit" accesskey="s"/> as 
-    <input type="text" name="author" id="authorName" value="<%= @author %>" 
-        onClick="this.value == 'AnonymousCoward' ? this.value = '' : true" />
+    <input type="submit" value="Submit" accesskey="s"/> as <%= @author %>
+    <input type="hidden" name="author" id="authorName" value="<%= @author %>" />
     | 
     <%= link_to('Cancel', {:web => @web.address, :action => 'cancel_edit', :id => @page.name},
           {:accesskey => 'c'})
Index: instiki/app/views/wiki/new.rhtml
===================================================================
--- instiki/app/views/wiki/new.rhtml	(revision 12190)
+++ instiki/app/views/wiki/new.rhtml	(working copy)
@@ -17,8 +17,8 @@
     <textarea name="content" style="width: 450px; height: 500px"><%= h(@flash[:content] || '') %></textarea>
 </p>
 <p>
-    <input type="submit" value="Submit" accesskey="s"/> as 
-    <input type="text" name="author" id="authorName" value="<%= @author %>" onClick="this.value == 'AnonymousCoward' ? this.value = '' : true" />
+    <input type="submit" value="Submit" accesskey="s"/> as <%= @author %>
+    <input type="hidden" name="author" id="authorName" value="<%= @author %>" />
 </p>
 <%= end_form_tag %>
 
_______________________________________________
Instiki-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/instiki-users

Reply via email to