Updated MANIFEST.
Bumped for release.
scripts/edit_host_settings_form.ml
scripts/edit_page_css.ml
scripts/edit_page_css_form.ml
+scripts/edit_page_title.ml
+scripts/edit_page_title_form.ml
scripts/edit_sitemenu.ml
scripts/edit_user.ml
scripts/edit_user_form.ml
templates/edit_host_settings_form.html
templates/edit_page_css_form.html
templates/edit_page_email.txt
+templates/edit_page_title_form.html
templates/edit_sitemenu.html
templates/edit_user_form.html
templates/files.html
# Apache configuration for COCANWIKI.
-# $Id: cocanwiki.conf,v 1.10 2004/09/24 17:07:10 rich Exp $
+# $Id: cocanwiki.conf,v 1.11 2004/09/25 16:05:03 rich Exp $
# Uncomment the following lines if necessary. You will probably need
# to adjust the paths to reflect where cocanwiki is really installed.
RewriteRule ^/([^_].*)/diff$ /_bin/diff.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/edit$ /_bin/edit.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/editcss$ /_bin/edit_page_css_form.cmo?page=$1 [PT,L,QSA]
+RewriteRule ^/([^_].*)/edittitle$ /_bin/edit_page_title_form.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/history$ /_bin/history.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/index.rss$ /_bin/rss.cmo?page=$1 [PT,L,QSA]
RewriteRule ^/([^_].*)/stats$ /_bin/stats.cmo?page=$1 [PT,L,QSA]
-cocanwiki (1.1.1-4) unstable; urgency=low
+cocanwiki (1.1.1-5) unstable; urgency=low
* Initial Release.
# Makefile for COCANWIKI.
-# $Id: Makefile,v 1.26 2004/09/25 13:17:00 rich Exp $
+# $Id: Makefile,v 1.27 2004/09/25 16:05:03 rich Exp $
include ../Makefile.config
edit_host_settings_form.cmo \
edit_page_css.cmo \
edit_page_css_form.cmo \
+ edit_page_title.cmo \
+ edit_page_title_form.cmo \
edit_sitemenu.cmo \
edit_user.cmo \
edit_user_form.cmo \
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: edit_page_title.ml,v 1.1 2004/09/25 16:05:03 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_ok
+open Cocanwiki_emailnotify
+open Cocanwiki_strings
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user =
+ let page = q#param "page" in
+ let new_title = trim (q#param "title") in
+
+ (* Get the old title. *)
+ let sth = dbh#prepare_cached "select title from pages
+ where hostid = ? and url = ?" in
+ sth#execute [`Int hostid; `String page];
+
+ let old_title = sth#fetch1string () in
+
+ (* New title mustn't be empty string. *)
+ if new_title = "" then (
+ error ~back_button:true ~title:"Empty title not allowed"
+ q "The new title cannot be empty.";
+ return ()
+ );
+
+ (* If it's the index page, then they can change the title however
+ * they want. On other pages, however, you are only allowed limited
+ * edits which preserve the title -> url mapping.
+ *)
+ if page <> "index" then (
+ let new_page =
+ match Wikilib.generate_url_of_title dbh hostid new_title with
+ Wikilib.GenURL_OK url -> url
+ | Wikilib.GenURL_TooShort
+ | Wikilib.GenURL_BadURL -> ""
+ | Wikilib.GenURL_Duplicate url -> url in
+
+ if new_page <> page then (
+ error ~back_button:true ~title:"Title altered too much"
+ q ("The new title is too different from the old one. You can only " ^
+ "make limited changes to the title of a page. The manual " ^
+ "describes why, and how to copy pages instead.");
+ return ()
+ )
+ );
+
+ (* Get the IP address of the user, if available. *)
+ let logged_ip =
+ try `String (Connection.remote_ip (Request.connection r))
+ with Not_found -> `Null in
+
+ let logged_user =
+ match user with
+ | User (id, _, _) -> `Int id
+ | _ -> `Null in
+
+ (* Changing the title creates a new version of the page. This enables
+ * us to revert changes.
+ *)
+ let sth = dbh#prepare_cached "select id, description, creation_date,
+ redirect, css
+ from pages
+ where hostid = ? and url = ?" in
+ sth#execute [`Int hostid; `String page];
+
+ let oldpageid, description, creation_date, redirect, css =
+ match sth#fetch1 () with
+ [ `Int id; description; creation_date; redirect; css ] ->
+ id, description, creation_date, redirect, css
+ | _ -> assert false in
+
+ let sth = dbh#prepare_cached
+ "set constraints pages_redirect_cn, sitemenu_url_cn,
+ page_emails_url_cn deferred" in
+ sth#execute [];
+
+ let sth = dbh#prepare_cached "update pages set url_deleted = url,
+ url = null
+ where hostid = ? and id = ?" in
+ sth#execute [`Int hostid; `Int oldpageid];
+
+ let sth = dbh#prepare_cached "insert into pages (hostid, url, title,
+ description, creation_date, logged_ip,
+ logged_user, redirect, css)
+ values (?, ?, ?, ?, ?, ?, ?, ?, ?)" in
+ sth#execute [`Int hostid; `String page; `String new_title; description;
+ creation_date; logged_ip; logged_user; redirect; css ];
+
+ let pageid = sth#serial "pages_id_seq" in
+
+ let sth = dbh#prepare_cached "insert into contents (pageid, ordering,
+ sectionname, content, divname)
+ select ? as pageid, ordering, sectionname,
+ content, divname
+ from contents
+ where pageid = ?" in
+ sth#execute [`Int pageid; `Int oldpageid];
+
+ dbh#commit ();
+
+ (* Email notification. *)
+ let subject = "Title of page " ^ page ^ " has been modified" in
+ let body = fun () ->
+ "Page: http://" ^ hostname ^ "/" ^ page ^ "\n\n" ^
+ "Old title: " ^ old_title ^ "\n" ^
+ "New title: " ^ new_title ^ "\n" in
+
+ email_notify ~subject ~body dbh hostid;
+
+ let buttons = [ ok_button ("/" ^ page) ] in
+ ok ~title:"Title changed" ~buttons
+ q "The page title was changed successfully."
+
+let () =
+ register_script ~restrict:[CanEdit] run
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: edit_page_title_form.ml,v 1.1 2004/09/25 16:05:03 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 "edit_page_title_form.html" in
+
+ let page = q#param "page" in
+
+ let sth = dbh#prepare_cached "select title from pages
+ where hostid = ? and url = ?" in
+ sth#execute [`Int hostid; `String page];
+
+ let title = sth#fetch1string () in
+
+ template#set "page" page;
+ template#conditional "limited_changes" (page <> "index");
+ template#set "title" title;
+
+ q#template template
+
+let () =
+ register_script ~restrict:[CanEdit] run
(* 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.6 2004/09/17 15:09:48 rich Exp $
+ * $Id: wikilib.ml,v 1.7 2004/09/25 16:05:03 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
let generate_url_of_title (dbh : Dbi.connection) hostid title =
(* Create a suitable URL from this title. *)
- let url = String.map (function '\000' .. ' ' | '<' | '>' | '&' | '"' -> '_'
- | c -> Char.lowercase c) title in
+ let url =
+ String.map (function '\000' .. ' ' | '<' | '>' | '&' | '"' | '+' -> '_'
+ | c -> Char.lowercase c) title in
(* Check URL is not too trivial. *)
if not (Pcre.pmatch ~rex:nontrivial_re url) then
--- /dev/null
+<!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>Edit page title</title>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Edit page title</h1>
+
+<form method="post" action="/_bin/edit_page_title.cmo">
+<input type="hidden" name="page" value="::page_html_tag::"/>
+<table class="left_table">
+<tr>
+<th> Current title: </th> <td> <strong>::title_html::</strong> </td>
+</tr>
+
+<tr>
+<th> New title: </th>
+<td> <input name="title" value="::title_html_tag::" size="50" /> </td>
+</tr>
+
+::if(limited_changes)::
+<tr>
+<th> Warning: </th>
+<td>
+You can only make limited changes to this title, such as
+changing lowercase to Uppercase.
+<a target="_blank" href="http://help.merjis.com/title_changes">Why is this?</a>
+</td>
+</tr>
+::end::
+
+<tr>
+<td></td>
+<td> <input type="submit" value=" Save changes "/> </td>
+</tr>
+</table>
+</form>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<div id="menu_div">
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+</div>
+
+<div id="footer_div">
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright © ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+</div>
+
+</body>
+</html>
\ No newline at end of file
<li> <a href="/_recent">Recent changes</a> </li>
<li> <a href="/::page_html_tag::/history">Versions of this page</a> </li>
<li> <a href="/::page_html_tag::/editcss">Edit stylesheet for this page</a> </li>
+<li> <a href="/::page_html_tag::/edittitle">Edit title</a> </li>
<li> <a href="/_bin/edit_sitemenu.cmo">Edit site menu</a> </li>
<li> <a href="/_bin/largest_pages.cmo">Largest pages</a> </li>
<li> <a href="/_images">Images</a> </li>