Fossil SCM

Corrected incorrect access rights check (did require Setup rights). Documentation corrections/additions. A few style conformance formatting changes.

stephan 2008-02-03 17:22 trunk
Commit b81e93f576cbddf770771c6835864bfc3e6061c9
1 file changed +29 -27
+29 -27
--- src/tagview.c
+++ src/tagview.c
@@ -28,21 +28,19 @@
2828
#include <assert.h>
2929
#include "config.h"
3030
#include "tagview.h"
3131
3232
/**
33
-tagview_strxform_f is a typedef for funcs with
34
-the following policy:
35
-
36
-The accept a string which they then transform into
37
-some other form. They return a transformed copy,
38
-which the caller is responsible for freeing.
39
-
40
-The intention of this is to provide a way for
41
-a generic query routine to format specific column
42
-data (e.g. transform an object ID into a link to
43
-that object).
33
+tagview_strxform_f is a typedef for funcs with the following policy:
34
+
35
+They accept a const string which they then transform into some other
36
+form. They return a transformed copy, which the caller is responsible
37
+for freeing.
38
+
39
+The intention of this is to provide a way for a generic query routine
40
+to format specific column data (e.g. transform an object ID into a
41
+link to that object).
4442
*/
4543
typedef char * (*tagview_strxform_f)( char const * );
4644
4745
#if 0
4846
/** A no-op transformer which can be used as a placeholder. */
@@ -57,30 +55,30 @@
5755
#endif
5856
5957
/** Returns a hyperlink to uuid. */
6058
static char * tagview_xf_link_to_uuid( char const * uuid )
6159
{
62
- const int offset = 10;
63
- char shortname[offset+1];
64
- shortname[offset] = '\0';
65
- memcpy( shortname, uuid, offset );
66
- return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>",
67
- g.zBaseURL, uuid, shortname, uuid+offset );
60
+ const int offset = 10;
61
+ char shortname[offset+1];
62
+ shortname[offset] = '\0';
63
+ memcpy( shortname, uuid, offset );
64
+ return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>",
65
+ g.zBaseURL, uuid, shortname, uuid+offset );
6866
}
6967
7068
/** Returns a hyperlink to the given tag. */
7169
static char * tagview_xf_link_to_tagid( char const * tagid )
7270
{
7371
return mprintf( "<a href='%s/tagview?tagid=%s'>%s</a>",
74
- g.zBaseURL, tagid, tagid );
72
+ g.zBaseURL, tagid, tagid );
7573
}
7674
7775
/** Returns a hyperlink to the named tag. */
7876
static char * tagview_xf_link_to_tagname( char const * tagid )
7977
{
8078
return mprintf( "<a href='%s/tagview/%s'>%s</a>",
81
- g.zBaseURL, tagid, tagid );
79
+ g.zBaseURL, tagid, tagid );
8280
}
8381
8482
8583
8684
/**
@@ -90,21 +88,21 @@
9088
* results.
9189
*
9290
* The sql parameter should be a single, complete SQL statement.
9391
*
9492
* The coln parameter is optional (it may be 0). If it is 0 then the
95
-* column names using in the output will be taken directly from the
93
+* column names used in the output will be taken directly from the
9694
* SQL. If it is not null then it must have as many entries as the SQL
9795
* result has columns. Each entry is a column name for the SQL result
9896
* column of the same index. Any given entry may be 0, in which case
9997
* the column name from the SQL is used.
10098
*
10199
* The xform argument is an array of transformation functions (type
102100
* tagview_strxform_f). The array, or any single entry, may be 0, but
103101
* if the array is non-0 then it must have at least as many entries as
104102
* colnames does. Each index corresponds directly to an entry in
105
-* colnames and the SQL results. Any given entry may be 0 If it has
103
+* colnames and the SQL results. Any given entry may be 0. If it has
106104
* fewer, undefined behaviour results. If a column has an entry in
107105
* xform, then the xform function will be called to transform the
108106
* column data before rendering it. This function takes care of freeing
109107
* the strings created by the xform functions.
110108
*
@@ -154,11 +152,10 @@
154152
@ <td>%s(db_column_name(&st,i))</td>
155153
}
156154
}
157155
@ </tr>
158156
159
-
160157
while( SQLITE_ROW == db_step(&st) ){
161158
@ <tr>
162159
for( i = 0; i < colc; ++i ) {
163160
char * xf = 0;
164161
char const * xcf = 0;
@@ -189,17 +186,18 @@
189186
@ <h2>Tags matching [%s(likeclause)]:</h2>
190187
}
191188
else
192189
{
193190
limitstr = mprintf( "LIMIT %d", limit );
194
- @ <h2>%d(limit) most recent tags:</h2>
191
+ @ <h2>%d(limit) most recent non-wiki tags:</h2>
195192
}
196193
char * sql = mprintf(
197194
"SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid "
198195
"FROM tag t, tagxref tx, blob b "
199196
"WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) "
200197
"AND (tx.tagtype != 0) %s "
198
+ "AND t.tagname NOT GLOB 'wiki-*' "
201199
"ORDER BY tx.mtime DESC %s",
202200
likeclause ? likeclause : " ",
203201
limitstr ? limitstr : " "
204202
);
205203
/* " AND t.tagname NOT GLOB 'wiki-*'" // Do we want this?? */
@@ -229,11 +227,13 @@
229227
@ <input type='submit'/>
230228
@ </form>
231229
@ </div>
232230
}
233231
234
-
232
+/**
233
+ tagview_page_default() renders the default page for tagview_page().
234
+*/
235235
static void tagview_page_default(void){
236236
tagview_page_list_tags( 0 );
237237
}
238238
239239
/**
@@ -244,20 +244,21 @@
244244
@ <h2>Tag #%d(tagid):</h2>
245245
char * sql = mprintf(
246246
"SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid "
247247
"FROM tag t, tagxref tx, blob b "
248248
"WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
249
+ "AND t.tagname NOT GLOB 'wiki-*' "
249250
"ORDER BY tx.mtime DESC",
250251
tagid);
251252
char const * const colnames[] = {
252253
"Tag Name", "Timestamp", "Version"
253
- };
254
+ };
254255
tagview_strxform_f xf[] = {
255256
tagview_xf_link_to_tagname,
256257
0,
257258
tagview_xf_link_to_uuid
258
- };
259
+ };
259260
tagview_run_query( sql, colnames, xf );
260261
free(sql);
261262
}
262263
263264
/**
@@ -268,10 +269,11 @@
268269
@ <h2>Tag '%s(tagname)':</h2>
269270
char * sql = mprintf(
270271
"SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid "
271272
"FROM tag t, tagxref tx, blob b "
272273
"WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
274
+ "AND t.tagname NOT GLOB 'wiki-*' "
273275
"ORDER BY tx.mtime DESC",
274276
tagname);
275277
char const * const colnames[] = {
276278
"Tag ID", "Timestamp", "Version"
277279
};
@@ -289,11 +291,11 @@
289291
** WEBPAGE: /tagview
290292
*/
291293
void tagview_page(void){
292294
293295
login_check_credentials();
294
- if( !g.okSetup ){
296
+ if( !g.okRdWiki ){
295297
login_needed();
296298
}
297299
style_header("Tags");
298300
tagview_page_search_miniform();
299301
@ <hr/>
300302
--- src/tagview.c
+++ src/tagview.c
@@ -28,21 +28,19 @@
28 #include <assert.h>
29 #include "config.h"
30 #include "tagview.h"
31
32 /**
33 tagview_strxform_f is a typedef for funcs with
34 the following policy:
35
36 The accept a string which they then transform into
37 some other form. They return a transformed copy,
38 which the caller is responsible for freeing.
39
40 The intention of this is to provide a way for
41 a generic query routine to format specific column
42 data (e.g. transform an object ID into a link to
43 that object).
44 */
45 typedef char * (*tagview_strxform_f)( char const * );
46
47 #if 0
48 /** A no-op transformer which can be used as a placeholder. */
@@ -57,30 +55,30 @@
57 #endif
58
59 /** Returns a hyperlink to uuid. */
60 static char * tagview_xf_link_to_uuid( char const * uuid )
61 {
62 const int offset = 10;
63 char shortname[offset+1];
64 shortname[offset] = '\0';
65 memcpy( shortname, uuid, offset );
66 return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>",
67 g.zBaseURL, uuid, shortname, uuid+offset );
68 }
69
70 /** Returns a hyperlink to the given tag. */
71 static char * tagview_xf_link_to_tagid( char const * tagid )
72 {
73 return mprintf( "<a href='%s/tagview?tagid=%s'>%s</a>",
74 g.zBaseURL, tagid, tagid );
75 }
76
77 /** Returns a hyperlink to the named tag. */
78 static char * tagview_xf_link_to_tagname( char const * tagid )
79 {
80 return mprintf( "<a href='%s/tagview/%s'>%s</a>",
81 g.zBaseURL, tagid, tagid );
82 }
83
84
85
86 /**
@@ -90,21 +88,21 @@
90 * results.
91 *
92 * The sql parameter should be a single, complete SQL statement.
93 *
94 * The coln parameter is optional (it may be 0). If it is 0 then the
95 * column names using in the output will be taken directly from the
96 * SQL. If it is not null then it must have as many entries as the SQL
97 * result has columns. Each entry is a column name for the SQL result
98 * column of the same index. Any given entry may be 0, in which case
99 * the column name from the SQL is used.
100 *
101 * The xform argument is an array of transformation functions (type
102 * tagview_strxform_f). The array, or any single entry, may be 0, but
103 * if the array is non-0 then it must have at least as many entries as
104 * colnames does. Each index corresponds directly to an entry in
105 * colnames and the SQL results. Any given entry may be 0 If it has
106 * fewer, undefined behaviour results. If a column has an entry in
107 * xform, then the xform function will be called to transform the
108 * column data before rendering it. This function takes care of freeing
109 * the strings created by the xform functions.
110 *
@@ -154,11 +152,10 @@
154 @ <td>%s(db_column_name(&st,i))</td>
155 }
156 }
157 @ </tr>
158
159
160 while( SQLITE_ROW == db_step(&st) ){
161 @ <tr>
162 for( i = 0; i < colc; ++i ) {
163 char * xf = 0;
164 char const * xcf = 0;
@@ -189,17 +186,18 @@
189 @ <h2>Tags matching [%s(likeclause)]:</h2>
190 }
191 else
192 {
193 limitstr = mprintf( "LIMIT %d", limit );
194 @ <h2>%d(limit) most recent tags:</h2>
195 }
196 char * sql = mprintf(
197 "SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid "
198 "FROM tag t, tagxref tx, blob b "
199 "WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) "
200 "AND (tx.tagtype != 0) %s "
 
201 "ORDER BY tx.mtime DESC %s",
202 likeclause ? likeclause : " ",
203 limitstr ? limitstr : " "
204 );
205 /* " AND t.tagname NOT GLOB 'wiki-*'" // Do we want this?? */
@@ -229,11 +227,13 @@
229 @ <input type='submit'/>
230 @ </form>
231 @ </div>
232 }
233
234
 
 
235 static void tagview_page_default(void){
236 tagview_page_list_tags( 0 );
237 }
238
239 /**
@@ -244,20 +244,21 @@
244 @ <h2>Tag #%d(tagid):</h2>
245 char * sql = mprintf(
246 "SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid "
247 "FROM tag t, tagxref tx, blob b "
248 "WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
 
249 "ORDER BY tx.mtime DESC",
250 tagid);
251 char const * const colnames[] = {
252 "Tag Name", "Timestamp", "Version"
253 };
254 tagview_strxform_f xf[] = {
255 tagview_xf_link_to_tagname,
256 0,
257 tagview_xf_link_to_uuid
258 };
259 tagview_run_query( sql, colnames, xf );
260 free(sql);
261 }
262
263 /**
@@ -268,10 +269,11 @@
268 @ <h2>Tag '%s(tagname)':</h2>
269 char * sql = mprintf(
270 "SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid "
271 "FROM tag t, tagxref tx, blob b "
272 "WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
 
273 "ORDER BY tx.mtime DESC",
274 tagname);
275 char const * const colnames[] = {
276 "Tag ID", "Timestamp", "Version"
277 };
@@ -289,11 +291,11 @@
289 ** WEBPAGE: /tagview
290 */
291 void tagview_page(void){
292
293 login_check_credentials();
294 if( !g.okSetup ){
295 login_needed();
296 }
297 style_header("Tags");
298 tagview_page_search_miniform();
299 @ <hr/>
300
--- src/tagview.c
+++ src/tagview.c
@@ -28,21 +28,19 @@
28 #include <assert.h>
29 #include "config.h"
30 #include "tagview.h"
31
32 /**
33 tagview_strxform_f is a typedef for funcs with the following policy:
34
35 They accept a const string which they then transform into some other
36 form. They return a transformed copy, which the caller is responsible
37 for freeing.
38
39 The intention of this is to provide a way for a generic query routine
40 to format specific column data (e.g. transform an object ID into a
41 link to that object).
 
 
42 */
43 typedef char * (*tagview_strxform_f)( char const * );
44
45 #if 0
46 /** A no-op transformer which can be used as a placeholder. */
@@ -57,30 +55,30 @@
55 #endif
56
57 /** Returns a hyperlink to uuid. */
58 static char * tagview_xf_link_to_uuid( char const * uuid )
59 {
60 const int offset = 10;
61 char shortname[offset+1];
62 shortname[offset] = '\0';
63 memcpy( shortname, uuid, offset );
64 return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>",
65 g.zBaseURL, uuid, shortname, uuid+offset );
66 }
67
68 /** Returns a hyperlink to the given tag. */
69 static char * tagview_xf_link_to_tagid( char const * tagid )
70 {
71 return mprintf( "<a href='%s/tagview?tagid=%s'>%s</a>",
72 g.zBaseURL, tagid, tagid );
73 }
74
75 /** Returns a hyperlink to the named tag. */
76 static char * tagview_xf_link_to_tagname( char const * tagid )
77 {
78 return mprintf( "<a href='%s/tagview/%s'>%s</a>",
79 g.zBaseURL, tagid, tagid );
80 }
81
82
83
84 /**
@@ -90,21 +88,21 @@
88 * results.
89 *
90 * The sql parameter should be a single, complete SQL statement.
91 *
92 * The coln parameter is optional (it may be 0). If it is 0 then the
93 * column names used in the output will be taken directly from the
94 * SQL. If it is not null then it must have as many entries as the SQL
95 * result has columns. Each entry is a column name for the SQL result
96 * column of the same index. Any given entry may be 0, in which case
97 * the column name from the SQL is used.
98 *
99 * The xform argument is an array of transformation functions (type
100 * tagview_strxform_f). The array, or any single entry, may be 0, but
101 * if the array is non-0 then it must have at least as many entries as
102 * colnames does. Each index corresponds directly to an entry in
103 * colnames and the SQL results. Any given entry may be 0. If it has
104 * fewer, undefined behaviour results. If a column has an entry in
105 * xform, then the xform function will be called to transform the
106 * column data before rendering it. This function takes care of freeing
107 * the strings created by the xform functions.
108 *
@@ -154,11 +152,10 @@
152 @ <td>%s(db_column_name(&st,i))</td>
153 }
154 }
155 @ </tr>
156
 
157 while( SQLITE_ROW == db_step(&st) ){
158 @ <tr>
159 for( i = 0; i < colc; ++i ) {
160 char * xf = 0;
161 char const * xcf = 0;
@@ -189,17 +186,18 @@
186 @ <h2>Tags matching [%s(likeclause)]:</h2>
187 }
188 else
189 {
190 limitstr = mprintf( "LIMIT %d", limit );
191 @ <h2>%d(limit) most recent non-wiki tags:</h2>
192 }
193 char * sql = mprintf(
194 "SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid "
195 "FROM tag t, tagxref tx, blob b "
196 "WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) "
197 "AND (tx.tagtype != 0) %s "
198 "AND t.tagname NOT GLOB 'wiki-*' "
199 "ORDER BY tx.mtime DESC %s",
200 likeclause ? likeclause : " ",
201 limitstr ? limitstr : " "
202 );
203 /* " AND t.tagname NOT GLOB 'wiki-*'" // Do we want this?? */
@@ -229,11 +227,13 @@
227 @ <input type='submit'/>
228 @ </form>
229 @ </div>
230 }
231
232 /**
233 tagview_page_default() renders the default page for tagview_page().
234 */
235 static void tagview_page_default(void){
236 tagview_page_list_tags( 0 );
237 }
238
239 /**
@@ -244,20 +244,21 @@
244 @ <h2>Tag #%d(tagid):</h2>
245 char * sql = mprintf(
246 "SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid "
247 "FROM tag t, tagxref tx, blob b "
248 "WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
249 "AND t.tagname NOT GLOB 'wiki-*' "
250 "ORDER BY tx.mtime DESC",
251 tagid);
252 char const * const colnames[] = {
253 "Tag Name", "Timestamp", "Version"
254 };
255 tagview_strxform_f xf[] = {
256 tagview_xf_link_to_tagname,
257 0,
258 tagview_xf_link_to_uuid
259 };
260 tagview_run_query( sql, colnames, xf );
261 free(sql);
262 }
263
264 /**
@@ -268,10 +269,11 @@
269 @ <h2>Tag '%s(tagname)':</h2>
270 char * sql = mprintf(
271 "SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid "
272 "FROM tag t, tagxref tx, blob b "
273 "WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) "
274 "AND t.tagname NOT GLOB 'wiki-*' "
275 "ORDER BY tx.mtime DESC",
276 tagname);
277 char const * const colnames[] = {
278 "Tag ID", "Timestamp", "Version"
279 };
@@ -289,11 +291,11 @@
291 ** WEBPAGE: /tagview
292 */
293 void tagview_page(void){
294
295 login_check_credentials();
296 if( !g.okRdWiki ){
297 login_needed();
298 }
299 style_header("Tags");
300 tagview_page_search_miniform();
301 @ <hr/>
302

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button