From f281fd7b2ac035be5a15cc1519d395b4e383eb84 Mon Sep 17 00:00:00 2001 From: rich Date: Sun, 24 Oct 2004 17:32:54 +0000 Subject: [PATCH] "New page" button for creating new pages interactively. --- MANIFEST | 5 +++++ html/_css/new_page.css | 6 ++++++ html/_css/standard.css | 7 ++++++- html/_graphics/new.png | Bin 0 -> 247 bytes html/_js/new_page.js | 35 ++++++++++++++++++++++++++++++++ scripts/.depend | 2 ++ scripts/lib/wikilib.ml | 5 ++++- scripts/new_page_form.ml | 36 +++++++++++++++++++++++++++++++++ templates/new_page_form.html | 47 +++++++++++++++++++++++++++++++++++++++++++ templates/page.html | 3 ++- 10 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 html/_css/new_page.css create mode 100644 html/_graphics/new.png create mode 100644 html/_js/new_page.js create mode 100644 scripts/new_page_form.ml create mode 100644 templates/new_page_form.html diff --git a/MANIFEST b/MANIFEST index 093cf9f..7f1643b 100644 --- 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 index 0000000..053e91f --- /dev/null +++ b/html/_css/new_page.css @@ -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 diff --git a/html/_css/standard.css b/html/_css/standard.css index e26105f..39d4379 100644 --- a/html/_css/standard.css +++ b/html/_css/standard.css @@ -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 index 0000000000000000000000000000000000000000..16d1846ce796d52d5d2da745c10b42c9ea225c61 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPWmjoY&_LsS5K}O1!xJHyX=jZ08=9Mrw7o{eaq^2m8 zXO?6rgk+>DxO@5ryiZZh11gO6ba4!+xRsnBk#T?{S>n9S=l^daLp+m{+1fV0RO>k+ zIkoJWy;XvTHS@s=24ThG|L0B84y1E9GD}=Oe`s%q@4VIpZ!_2?zF~4oxYCfA$iQ86 i?BLXh2a?>~77SZ1YMFPnEPW2NhQZU-&t;ucLK6Ul`%x+Y literal 0 HcmV?d00001 diff --git a/html/_js/new_page.js b/html/_js/new_page.js new file mode 100644 index 0000000..f4e3d16 --- /dev/null +++ b/html/_js/new_page.js @@ -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, "&"); + title = title.replace (//g, ">"); + title = title.replace (/\"/g, """); + div.innerHTML = "You can create links to this page when editing by putting two square brackets around the page name, like this:

[[" + title + "]]"; + } +} diff --git a/scripts/.depend b/scripts/.depend index ae973c3..6eff1f2 100644 --- a/scripts/.depend +++ b/scripts/.depend @@ -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 diff --git a/scripts/lib/wikilib.ml b/scripts/lib/wikilib.ml index 0ba0425..7916201 100644 --- a/scripts/lib/wikilib.ml +++ b/scripts/lib/wikilib.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * 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 index 0000000..f68ab9b --- /dev/null +++ b/scripts/new_page_form.ml @@ -0,0 +1,36 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * 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 index 0000000..c9b5e16 --- /dev/null +++ b/templates/new_page_form.html @@ -0,0 +1,47 @@ + + + +New page + + + + + + + + +

New page

+ +

+ Note that you would normally create a new page just by +clicking on any link like this. +

+ +
+ + + + + + + + + + + + + +
Page name:
+ +
+
+ +::include(footer.html):: + + \ No newline at end of file diff --git a/templates/page.html b/templates/page.html index c1cd142..92d4a29 100644 --- a/templates/page.html +++ b/templates/page.html @@ -70,7 +70,8 @@
  • Versions of this page
  • What links here?
  • Edit stylesheet
  • -
  • Rename page
  • +
  • Rename page
  • +
  • New page
  • Images
  • Files
  • ::if(has_stats):: -- 1.8.3.1