Overview
SHA1 Hash: | 61ce5e3685fb867ff382c7336f96d9b1033f71ad |
---|---|
Date: | 2007-10-10 23:10:48 |
User: | drh |
Comment: | Get rid of the "locking" capability on wiki pages. Assume that anybody who can write or append to a wiki page can do so to any wiki page. Add the /wikiappend page for appending comments to the end of wiki. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/login.c from [9dc968113f] to [f15d2f5703].
@@ -290,11 +290,11 @@ for(i=0; zCap[i]; i++){ switch( zCap[i] ){ case 's': g.okSetup = 1; case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okQuery = g.okRdWiki = g.okWrWiki = g.okNewWiki = - g.okHistory = g.okClone = + g.okApndWiki = g.okHistory = g.okClone = g.okNewTkt = g.okPassword = 1; case 'i': g.okRead = g.okWrite = 1; break; case 'o': g.okRead = 1; break; case 'd': g.okDelete = 1; break;
Modified src/main.c from [ef101c5a91] to [5b5ca5ba39].
@@ -99,11 +99,10 @@ int okClone; /* g: clone */ int okRdWiki; /* j: view wiki via web */ int okNewWiki; /* f: create new wiki via web */ int okApndWiki; /* m: append to wiki via web */ int okWrWiki; /* k: edit wiki via web */ - int okLockWiki; /* l: lock and unlock wiki via web */ int okRdTkt; /* r: view tickets via web */ int okNewTkt; /* n: create new tickets */ int okApndTkt; /* c: append to tickets via the web */ int okWrTkt; /* w: make changes to tickets via web */
Modified src/schema.c from [551d7af8e5] to [f8f803b8a2].
@@ -217,10 +217,13 @@ @ tagname TEXT UNIQUE -- Tag name. @ ); @ INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR @ INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT @ INSERT INTO tag VALUES(3, 'user'); -- TAG_USER +@ INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN +@ INSERT INTO tag VALUES(5, 'readonly'); -- TAG_READONLY +@ INSERT INTO tag VALUES(6, 'appendonly'); -- TAG_APPENDONLY @ @ -- Assignments of tags to baselines. Note that we allow tags to @ -- have values assigned to them. So we are not really dealing with @ -- tags here. These are really properties. But we are going to @ -- keep calling them tags because in many cases the value is ignored. @@ -242,10 +245,13 @@ */ #if INTERFACE # define TAG_BGCOLOR 1 # define TAG_COMMENT 2 # define TAG_USER 3 +# define TAG_HIDDEN 4 +# define TAG_READONLY 5 +# define TAG_APPENDONLY 6 #endif /* ** The schema for the locate FOSSIL database file found at the root ** of very check-out. This database contains the complete state of
Modified src/setup.c from [743163c8fa] to [9f35614dc3].
@@ -130,11 +130,10 @@ @ <li value="7"><b>Clone</b>: Clone the repository</li> @ <li value="8"><b>History</b>: View detail repository history</li> @ <li value="9"><b>Check-In</b>: Commit new versions in the repository</li> @ <li value="10"><b>Read-Wiki</b>: View wiki pages</li> @ <li value="11"><b>Write-Wiki</b>: Edit wiki pages</li> - @ <li value="12"><b>Lock-Wiki</b>: Lock or unlock wiki pages</li> @ <li value="13"><b>Append-Wiki</b>: Append to wiki pages</li> @ <li value="14"><b>New-Tkt</b>: Create new tickets</li> @ <li value="15"><b>Check-Out</b>: Check out versions</li> @ <li value="16"><b>Password</b>: Change your own password</li> @ <li value="17"><b>Query</b>: Create new queries against tickets</li> @@ -160,11 +159,11 @@ ** WEBPAGE: /setup_uedit */ void user_edit(void){ const char *zId, *zLogin, *zInfo, *zCap; char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap ; - char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag, *oal; + char *oak, *oad, *oaq, *oac, *oaf, *oam, *oah, *oag; int doWrite; int uid; int higherUser = 0; /* True if user being edited is SETUP and the */ /* user doing the editing is ADMIN. Disallow editing */ @@ -214,21 +213,19 @@ int ac = P("ac")!=0; int af = P("af")!=0; int am = P("am")!=0; int ah = P("ah")!=0; int ag = P("ag")!=0; - int al = P("al")!=0; if( aa ){ zCap[i++] = 'a'; } if( ac ){ zCap[i++] = 'c'; } if( ad ){ zCap[i++] = 'd'; } if( af ){ zCap[i++] = 'f'; } if( ah ){ zCap[i++] = 'h'; } if( ag ){ zCap[i++] = 'g'; } if( ai ){ zCap[i++] = 'i'; } if( aj ){ zCap[i++] = 'j'; } if( ak ){ zCap[i++] = 'k'; } - if( al ){ zCap[i++] = 'l'; } if( am ){ zCap[i++] = 'm'; } if( an ){ zCap[i++] = 'n'; } if( ao ){ zCap[i++] = 'o'; } if( ap ){ zCap[i++] = 'p'; } if( aq ){ zCap[i++] = 'q'; } @@ -265,11 +262,11 @@ /* Load the existing information about the user, if any */ zLogin = ""; zInfo = ""; zCap = ""; - oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oal = oam = + oaa = oac = oad = oaf = oag = oah = oai = oaj = oak = oam = oan = oao = oap = oaq = oar = oas = oaw = ""; if( uid ){ zLogin = db_text("", "SELECT login FROM user WHERE uid=%d", uid); zInfo = db_text("", "SELECT info FROM user WHERE uid=%d", uid); zCap = db_text("", "SELECT cap FROM user WHERE uid=%d", uid); @@ -280,11 +277,10 @@ if( strchr(zCap, 'g') ) oag = " checked"; if( strchr(zCap, 'h') ) oah = " checked"; if( strchr(zCap, 'i') ) oai = " checked"; if( strchr(zCap, 'j') ) oaj = " checked"; if( strchr(zCap, 'k') ) oak = " checked"; - if( strchr(zCap, 'l') ) oal = " checked"; if( strchr(zCap, 'm') ) oam = " checked"; if( strchr(zCap, 'n') ) oan = " checked"; if( strchr(zCap, 'o') ) oao = " checked"; if( strchr(zCap, 'p') ) oap = " checked"; if( strchr(zCap, 'q') ) oaq = " checked"; @@ -336,11 +332,10 @@ @ <input type="checkbox" name="ag"%s(oag)>Clone</input><br> @ <input type="checkbox" name="aj"%s(oaj)>Read Wiki</input><br> @ <input type="checkbox" name="af"%s(oaf)>New Wiki</input><br> @ <input type="checkbox" name="am"%s(oam)>Append Wiki</input><br> @ <input type="checkbox" name="ak"%s(oak)>Write Wiki</input><br> - @ <input type="checkbox" name="al"%s(oak)>Lock Wiki</input><br> @ <input type="checkbox" name="ar"%s(oar)>Read Tkt</input><br> @ <input type="checkbox" name="an"%s(oan)>New Tkt</input><br> @ <input type="checkbox" name="ac"%s(oac)>Append Tkt</input><br> @ <input type="checkbox" name="aw"%s(oaw)>Write Tkt</input> @ </td>
Modified src/wiki.c from [9a9d53861a] to [c34537ff45].
@@ -105,11 +105,10 @@ void wiki_page(void){ char *zTag; int rid; Blob wiki; Manifest m; - int seenHr = 0; char *zPageName; char *zHtmlPageName; char *zBody = mprintf("%s","<i>Empty Page</i>"); login_check_credentials(); @@ -134,11 +133,15 @@ zBody = m.zWiki; } } if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){ style_submenu_element("Edit", "Edit Wiki Page", - mprintf("%s/wikiedit/%s", g.zTop, g.zExtra)); + mprintf("%s/wikiedit/%s", g.zTop, g.zExtra)); + } + if( rid && g.okApndWiki ){ + style_submenu_element("Append", "Add A Comment", + mprintf("%s/wikiappend/%s", g.zTop, g.zExtra)); } if( g.okHistory ){ style_submenu_element("History", "History", mprintf("%s/whistory/%s", g.zTop, g.zExtra)); } @@ -146,24 +149,10 @@ style_header(zHtmlPageName); blob_init(&wiki, zBody, -1); wiki_convert(&wiki, 0); blob_reset(&wiki); manifest_clear(&m); -#if 0 - if( (rid && g.okWrWiki) || (!rid && g.okNewWiki) ){ - @ <hr> - @ [<a href="%s(g.zBaseURL)/wikiedit/%s(g.zExtra)">Edit</a>] - seenHr = 1; - } - if( g.okHistory ){ - if( !seenHr ){ - @ <hr> - seenHr = 1; - } - @ [<a href="%s(g.zBaseUrl)/whistory/%s(g.zExtra)">History</a>] - } -#endif style_footer(); } /* ** WEBPAGE: wikiedit @@ -269,11 +258,133 @@ @ <input type="submit" name="submit" value="Apply These Changes"> @ <input type="submit" name="cancel" value="Cancel"> @ </form> manifest_clear(&m); style_footer(); +} + +/* +** Append the wiki text for an remark to the end of the given BLOB. +*/ +static void appendRemark(Blob *p){ + char *zDate; + const char *zUser; + const char *zRemark; + + zDate = db_text(0, "SELECT datetime('now')"); + blob_appendf(p, "On %s UTC %h", zDate, g.zLogin); + free(zDate); + zUser = PD("u",g.zLogin); + if( zUser[0] && strcmp(zUser,g.zLogin) ){ + blob_appendf(p, " (claiming to be %h)", zUser); + } + zRemark = PD("r",""); + blob_appendf(p, " added:\n\n%s", zRemark); +} + +/* +** WEBPAGE: wikiappend +** URL: /wikiappend/PAGENAME +*/ +void wikiappend_page(void){ + char *zTag; + int rid; + char *zPageName; + char *zHtmlPageName; + const char *zUser; + + login_check_credentials(); + zPageName = mprintf("%s", g.zExtra); + dehttpize(zPageName); + if( check_name(zPageName) ) return; + zTag = mprintf("wiki-%s", zPageName); + rid = db_int(0, + "SELECT rid FROM tagxref" + " WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)" + " ORDER BY mtime DESC", zTag + ); + free(zTag); + if( !rid ){ + cgi_redirect("index"); + return; + } + if( !g.okApndWiki ){ + login_needed(); + return; + } + if( P("submit")!=0 && P("r")!=0 && P("u")!=0 ){ + char *zDate; + Blob cksum; + int nrid; + Blob body; + Blob content; + Blob wiki; + Manifest m; + content_get(rid, &content); + manifest_parse(&m, &content); + blob_zero(&body); + if( m.type==CFTYPE_WIKI ){ + blob_appendf(&body, m.zWiki, -1); + } + manifest_clear(&m); + blob_zero(&wiki); + db_begin_transaction(); + zDate = db_text(0, "SELECT datetime('now')"); + zDate[10] = 'T'; + blob_appendf(&wiki, "D %s\n", zDate); + blob_appendf(&wiki, "L %F\n", zPageName); + if( rid ){ + char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); + blob_appendf(&wiki, "P %s\n", zUuid); + free(zUuid); + } + if( g.zLogin ){ + blob_appendf(&wiki, "U %F\n", g.zLogin); + } + blob_appendf(&body, "\n<hr>\n"); + appendRemark(&body); + blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body)); + md5sum_blob(&wiki, &cksum); + blob_appendf(&wiki, "Z %b\n", &cksum); + blob_reset(&cksum); + nrid = content_put(&wiki, 0, 0); + db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); + manifest_crosslink(nrid, &wiki); + blob_reset(&wiki); + content_deltify(rid, nrid, 0); + db_end_transaction(0); + cgi_redirect(mprintf("wiki/%s", g.zExtra)); + } + if( P("cancel")!=0 ){ + cgi_redirect(mprintf("wiki/%s", g.zExtra)); + return; + } + zHtmlPageName = mprintf("Append Comment To: %h", zPageName); + style_header(zHtmlPageName); + if( P("preview")!=0 ){ + Blob preview; + blob_zero(&preview); + appendRemark(&preview); + @ Preview:<hr> + wiki_convert(&preview, 0); + @ <hr> + blob_reset(&preview); + } + zUser = PD("u", g.zLogin); + @ <form method="POST" action="%s(g.zBaseURL)/wikiappend/%t(g.zExtra)"> + @ Your Name: + @ <input type="text" name="u" size="20" value="%h(zUser)"><br> + @ Comment to append:<br> + @ <textarea name="r" class="wikiedit" cols="80" + @ rows="10" wrap="virtual">%h(PD("r",""))</textarea> + @ <br> + @ <input type="submit" name="preview" value="Preview Your Comment"> + @ <input type="submit" name="submit" value="Append Your Changes"> + @ <input type="submit" name="cancel" value="Cancel"> + @ </form> + style_footer(); } /* ** WEBPAGE: whistory **