"New page" button for creating new pages interactively.
authorrich <rich>
Sun, 24 Oct 2004 17:32:54 +0000 (17:32 +0000)
committerrich <rich>
Sun, 24 Oct 2004 17:32:54 +0000 (17:32 +0000)
MANIFEST
html/_css/new_page.css [new file with mode: 0644]
html/_css/standard.css
html/_graphics/new.png [new file with mode: 0644]
html/_js/new_page.js [new file with mode: 0644]
scripts/.depend
scripts/lib/wikilib.ml
scripts/new_page_form.ml [new file with mode: 0644]
templates/new_page_form.html [new file with mode: 0644]
templates/page.html

index 093cf9f..7f1643b 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -21,6 +21,7 @@ html/_css/files.css
 html/_css/images.css
 html/_css/login.css
 html/_css/markup.css
+html/_css/new_page.css
 html/_css/print.css
 html/_css/standard.css
 html/_css/stats_top.css
@@ -41,6 +42,7 @@ html/_graphics/images.png
 html/_graphics/maillist.png
 html/_graphics/mailto.png
 html/_graphics/markup-preview.png
+html/_graphics/new.png
 html/_graphics/newpage.png
 html/_graphics/ok.png
 html/_graphics/pinkhatch.png
@@ -52,6 +54,7 @@ html/_graphics/versions.png
 html/_graphics/wlh.png
 html/_graphics/xml.png
 html/_js/editor.js
+html/_js/new_page.js
 html/_js/visualise_links.js
 html/_js/wz_jsgraphics.js
 html/_static/markup.html
@@ -155,6 +158,7 @@ scripts/mailing_list_form.ml
 scripts/mailing_list_send.ml
 scripts/mailing_list_unsubscribe.ml
 scripts/mailing_list_view.ml
+scripts/new_page_form.ml
 scripts/page.ml
 scripts/page_email_confirm.ml
 scripts/page_email_form.ml
@@ -244,6 +248,7 @@ templates/mailing_list_form.html
 templates/mailing_list_send.txt
 templates/mailing_list_view.html
 templates/mailing_list_view.txt
+templates/new_page_form.html
 templates/ok_error.html
 templates/page.html
 templates/page_404.html
diff --git a/html/_css/new_page.css b/html/_css/new_page.css
new file mode 100644 (file)
index 0000000..053e91f
--- /dev/null
@@ -0,0 +1,6 @@
+/* $Id: new_page.css,v 1.1 2004/10/24 17:32:54 rich Exp $ */
+
+div#show_link {
+  width: 25em;
+  height: 8em;
+}
\ No newline at end of file
index e26105f..39d4379 100644 (file)
@@ -1,5 +1,5 @@
 /* Stylesheet for COCANWIKI.
- * $Id: standard.css,v 1.23 2004/10/23 09:47:24 rich Exp $
+ * $Id: standard.css,v 1.24 2004/10/24 17:32:54 rich Exp $
  */
 
 /* Based on the basic stylesheet. */
@@ -196,6 +196,11 @@ li.maillist_li a {
   background: url(/_graphics/maillist.png) center left no-repeat;
 }
 
+li.new_li a {
+  padding-left: 16px;
+  background: url(/_graphics/new.png) center left no-repeat;
+}
+
 li.recent_li a {
   padding-left: 18px;
   background: url(/_graphics/recent.png) center left no-repeat;
diff --git a/html/_graphics/new.png b/html/_graphics/new.png
new file mode 100644 (file)
index 0000000..16d1846
Binary files /dev/null and b/html/_graphics/new.png differ
diff --git a/html/_js/new_page.js b/html/_js/new_page.js
new file mode 100644 (file)
index 0000000..f4e3d16
--- /dev/null
@@ -0,0 +1,35 @@
+/* $Id: new_page.js,v 1.1 2004/10/24 17:32:54 rich Exp $ */
+
+var div;
+var timer;
+
+function init ()
+{
+  document.f.title.focus ();
+  document.f.submit.disabled = true;
+  div = document.getElementById ("show_link");
+}
+
+function update ()
+{
+  if (timer) clearTimeout (timer);
+  timer = setTimeout ("update_now ()", 1);
+}
+
+function update_now ()
+{
+  timer = null;
+
+  var title = document.f.title.value;
+  if (title.search (/[a-z0-9]/gi) == -1) {
+    document.f.submit.disabled = true;
+    div.innerHTML = "";
+  } else {
+    document.f.submit.disabled = false;
+    title = title.replace (/&/g, "&amp;");
+    title = title.replace (/</g, "&lt;");
+    title = title.replace (/>/g, "&gt;");
+    title = title.replace (/\"/g, "&quot;");
+    div.innerHTML = "You can create links to this page when editing by putting two square brackets around the page name, like this: <br/><br/> <code>[[" + title + "]]</code>";
+  }
+}
index ae973c3..6eff1f2 100644 (file)
@@ -216,6 +216,8 @@ mailing_list_view.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo \
     lib/cocanwiki_template.cmi 
 mailing_list_view.cmx: lib/cocanwiki.cmx lib/cocanwiki_date.cmx \
     lib/cocanwiki_template.cmx 
+new_page_form.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi 
+new_page_form.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx 
 page.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo lib/cocanwiki_links.cmi \
     lib/cocanwiki_ok.cmo lib/cocanwiki_server_settings.cmo \
     lib/cocanwiki_template.cmi lib/wikilib.cmi 
index 0ba0425..7916201 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: wikilib.ml,v 1.1 2004/10/21 11:42:05 rich Exp $
+ * $Id: wikilib.ml,v 1.2 2004/10/24 17:32:55 rich Exp $
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -55,6 +55,9 @@ let generate_url_of_title (dbh : Dbi.connection) hostid title =
   (* URL cannot begin with '_'. *)
   else if url.[0] = '_' then
     GenURL_BadURL
+  (* Titles which begin or end with spaces are probably mistakes. *)
+  else if isspace title.[0] || isspace title.[String.length title - 1] then
+    GenURL_BadURL
   else (
     (* Check that the URL doesn't already exist in the database.  If it does
      * then it probably means that another page exists with similar enough
diff --git a/scripts/new_page_form.ml b/scripts/new_page_form.ml
new file mode 100644 (file)
index 0000000..f68ab9b
--- /dev/null
@@ -0,0 +1,36 @@
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: new_page_form.ml,v 1.1 2004/10/24 17:32:54 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+  let template = get_template dbh hostid "new_page_form.html" in
+
+  q#template template
+
+let () =
+  register_script ~restrict:[CanEdit] run
diff --git a/templates/new_page_form.html b/templates/new_page_form.html
new file mode 100644 (file)
index 0000000..c9b5e16
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>New page</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+<link rel="stylesheet" href="/_css/new_page.css" type="text/css" title="Standard"/>
+<link rel="alternate stylesheet" href="/_css/easytoread.css" type="text/css" title="High contrast, big fonts"/>
+<script src="/_js/new_page.js" type="text/javascript"></script>
+</head><body onload="init();">
+
+<h1>New page</h1>
+
+<p>
+<em> Note that you would normally create a new page just by
+clicking on any <a href="#" class="newpage" title="Shows a link in the distinctive style for links to unknown pages.">link like this</a>. </em>
+</p>
+
+<form method="post" action="/_bin/edit.cmo" name="f">
+<table class="left_table">
+<tr>
+<th> Page name: </th>
+<td> <input name="title" value="" size="50" onkeypress="update(); return true;"/> </td>
+</tr>
+<tr>
+<td></td>
+<td>
+  <div id="show_link">
+  <noscript>
+  You can create links to this page when editing by putting
+  two square brackets around the page name, like this: <br/><br/>
+  <code>[[page name]]</code>
+  </noscript>
+  </div>
+</td>
+</tr>
+<tr>
+<td></td>
+<td> <input type="submit" name="submit" value="Create new page"/> </td>
+</tr>
+</table>
+</form>
+
+::include(footer.html)::
+</body>
+</html>
\ No newline at end of file
index c1cd142..92d4a29 100644 (file)
@@ -70,7 +70,8 @@
 <li class="versions_li"> <a href="/::page_html_tag::/history">Versions of this page</a> </li>
 <li class="wlh_li"> <a href="/_bin/what_links_here.cmo?page=::page_url::">What links here?</a> </li>
 <li class="stylesheet_li"> <a href="/::page_html_tag::/editcss">Edit stylesheet</a> </li>
-<li> <a href="/::page_html_tag::/edittitle">Rename page</a> </li>
+<li class="edittitle_li"> <a href="/::page_html_tag::/edittitle">Rename page</a> </li>
+<li class="new_li"> <a href="/_bin/new_page_form.cmo">New page</a> </li>
 <li class="images_li"> <a href="/_images">Images</a> </li>
 <li class="files_li"> <a href="/_files">Files</a> </li>
 ::if(has_stats)::