Fossil SCM

Fix the mimetype selector. Improved styling of the forum display.

drh 2018-06-20 01:35 forum-brainstorm-1
Commit 837b1cb59b580a108bc3033013cb162b1cae5c083feedc30141a6bee82c179b6
2 files changed +19 -6 +11 -11
--- src/default_css.txt
+++ src/default_css.txt
@@ -632,28 +632,41 @@
632632
vertical-align: top;
633633
text-align: right;
634634
padding: 0.2ex 1ex;
635635
}
636636
table.forum_post {
637
- top-margin: 1ex;
638
- bottom-margin: 1ex;
639
- left-margin: 0;
640
- right-margin: 0;
637
+ margin-top: 1ex;
638
+ margin-bottom: 1ex;
639
+ margin-left: 0;
640
+ margin-right: 0;
641641
border-spacing: 0;
642642
}
643643
span.forum_author {
644644
color: #888;
645
+ font-size: 75%;
646
+}
647
+span.forum_author::after {
648
+ content: " | ";
645649
}
646650
span.forum_age {
647651
color: #888;
648
- font-size: 75%;
652
+ font-size: 85%;
649653
}
650654
span.forum_buttons {
651
- font-size: 75%;
655
+ font-size: 85%;
656
+}
657
+span.forum_buttons::before {
658
+ color: #888;
659
+ content: " | ";
652660
}
653661
span.forum_npost {
654662
color: #888;
655663
font-size: 75%;
656664
}
657665
table.forumeditform td {
658666
vertical-align: top;
667
+ border-collapse: collapse;
668
+ padding: 1px;
669
+}
670
+div.forum_body p {
671
+ margin-top: 0;
659672
}
660673
--- src/default_css.txt
+++ src/default_css.txt
@@ -632,28 +632,41 @@
632 vertical-align: top;
633 text-align: right;
634 padding: 0.2ex 1ex;
635 }
636 table.forum_post {
637 top-margin: 1ex;
638 bottom-margin: 1ex;
639 left-margin: 0;
640 right-margin: 0;
641 border-spacing: 0;
642 }
643 span.forum_author {
644 color: #888;
 
 
 
 
645 }
646 span.forum_age {
647 color: #888;
648 font-size: 75%;
649 }
650 span.forum_buttons {
651 font-size: 75%;
 
 
 
 
652 }
653 span.forum_npost {
654 color: #888;
655 font-size: 75%;
656 }
657 table.forumeditform td {
658 vertical-align: top;
 
 
 
 
 
659 }
660
--- src/default_css.txt
+++ src/default_css.txt
@@ -632,28 +632,41 @@
632 vertical-align: top;
633 text-align: right;
634 padding: 0.2ex 1ex;
635 }
636 table.forum_post {
637 margin-top: 1ex;
638 margin-bottom: 1ex;
639 margin-left: 0;
640 margin-right: 0;
641 border-spacing: 0;
642 }
643 span.forum_author {
644 color: #888;
645 font-size: 75%;
646 }
647 span.forum_author::after {
648 content: " | ";
649 }
650 span.forum_age {
651 color: #888;
652 font-size: 85%;
653 }
654 span.forum_buttons {
655 font-size: 85%;
656 }
657 span.forum_buttons::before {
658 color: #888;
659 content: " | ";
660 }
661 span.forum_npost {
662 color: #888;
663 font-size: 75%;
664 }
665 table.forumeditform td {
666 vertical-align: top;
667 border-collapse: collapse;
668 padding: 1px;
669 }
670 div.forum_body p {
671 margin-top: 0;
672 }
673
+11 -11
--- src/forum.c
+++ src/forum.c
@@ -111,11 +111,11 @@
111111
char *zAge = db_timespan_name(rNow - rMTime);
112112
Blob body;
113113
@ <!-- Forum post %d(id) -->
114114
@ <table class="forum_post">
115115
@ <tr>
116
- @ <td class="forum_margin" width="%d(iDepth*25)" rowspan="2">
116
+ @ <td class="forum_margin" width="%d(iDepth*40)" rowspan="2">
117117
@ <td><span class="forum_author">%h(zUser)</span>
118118
@ <span class="forum_age">%s(zAge) ago</span>
119119
sqlite3_free(zAge);
120120
if( g.perm.WrForum ){
121121
@ <span class="forum_buttons">
@@ -167,11 +167,11 @@
167167
style_footer();
168168
}
169169
170170
/*
171171
** Use content in CGI parameters "s" (subject), "b" (body), and
172
-** "m" (mimetype) to create a new forum entry.
172
+** "mimetype" (mimetype) to create a new forum entry.
173173
** Return the id of the new forum entry.
174174
**
175175
** If any problems occur, return 0 and set *pzErr to a description of
176176
** the problem.
177177
**
@@ -183,11 +183,11 @@
183183
*/
184184
static int forum_post(int itemId, int parentId, char **pzErr){
185185
const char *zSubject = 0;
186186
int threadId;
187187
double rNow = db_double(0.0, "SELECT julianday('now')");
188
- const char *zMime = wiki_filter_mimetypes(P("m"));
188
+ const char *zMime = wiki_filter_mimetypes(P("mimetype"));
189189
if( itemId==0 && parentId==0 ){
190190
/* Start a new thread. Subject required. */
191191
sqlite3_uint64 r1, r2;
192192
zSubject = PT("s");
193193
if( zSubject==0 || zSubject[0]==0 ){
@@ -196,11 +196,11 @@
196196
}
197197
sqlite3_randomness(sizeof(r1), &r1);
198198
sqlite3_randomness(sizeof(r2), &r2);
199199
db_multi_exec(
200200
"INSERT INTO forumthread(mthreadhash, mtitle, mtime, npost)"
201
- "VALUES(lower(hex(randomblob(32))),%Q,%!.17g,1)",
201
+ "VALUES(lower(hex(randomblob(28))),%Q,%!.17g,1)",
202202
zSubject, rNow
203203
);
204204
threadId = db_last_insert_rowid();
205205
}else{
206206
threadId = db_int(0, "SELECT mthreadid FROM forumpost"
@@ -219,17 +219,17 @@
219219
" mtime=%!.17g,"
220220
" mimetype=%Q,"
221221
" ipaddr=%Q,"
222222
" mbody=%Q"
223223
" WHERE mpostid=%d",
224
- rNow, PT("m"), P("REMOTE_ADDR"), PT("b"), itemId
224
+ rNow, PT("mimetype"), P("REMOTE_ADDR"), PT("b"), itemId
225225
);
226226
}else{
227227
db_multi_exec(
228228
"INSERT INTO forumpost(mposthash,mthreadid,uname,mtime,"
229229
" mstatus,mimetype,ipaddr,inreplyto,mbody) VALUES"
230
- " (lower(hex(randomblob(32))),%d,%Q,%!.17g,%Q,%Q,%Q,nullif(%d,0),%Q)",
230
+ " (lower(hex(randomblob(28))),%d,%Q,%!.17g,%Q,%Q,%Q,nullif(%d,0),%Q)",
231231
threadId,g.zLogin,rNow,NULL,zMime,P("REMOTE_ADDR"),parentId,P("b"));
232232
itemId = db_last_insert_rowid();
233233
}
234234
if( zSubject==0 ){
235235
db_multi_exec(
@@ -275,25 +275,25 @@
275275
if( itemId ){
276276
cgi_redirectf("%R/forum?item=%d",itemId);
277277
return;
278278
}
279279
}
280
- if( itemId && (P("m")==0 || P("b")==0) ){
280
+ if( itemId && (P("mimetype")==0 || P("b")==0) ){
281281
Stmt q;
282282
db_prepare(&q, "SELECT mimetype, mbody FROM forumpost"
283283
" WHERE mpostid=%d", itemId);
284284
if( db_step(&q)==SQLITE_ROW ){
285
- if( P("m")==0 ){
286
- cgi_set_query_parameter("m", db_column_text(&q, 0));
285
+ if( P("mimetype")==0 ){
286
+ cgi_set_query_parameter("mimetype", db_column_text(&q, 0));
287287
}
288288
if( P("b")==0 ){
289289
cgi_set_query_parameter("b", db_column_text(&q, 1));
290290
}
291291
}
292292
db_finalize(&q);
293293
}
294
- zMime = wiki_filter_mimetypes(P("m"));
294
+ zMime = wiki_filter_mimetypes(P("mimetype"));
295295
if( itemId>0 ){
296296
style_header("Edit Forum Post");
297297
}else if( parentId>0 ){
298298
style_header("Comment On Forum Post");
299299
}else{
@@ -312,11 +312,11 @@
312312
if( P("s") ){
313313
@ <h1>%h(PT("s"))</h1>
314314
}
315315
@ <div class="forumpreviewbody">
316316
blob_init(&x, PT("b"), -1);
317
- wiki_render_by_mimetype(&x, PT("m"));
317
+ wiki_render_by_mimetype(&x, PT("mimetype"));
318318
blob_reset(&x);
319319
@ </div>
320320
@ </div>
321321
@ <hr>
322322
}
323323
--- src/forum.c
+++ src/forum.c
@@ -111,11 +111,11 @@
111 char *zAge = db_timespan_name(rNow - rMTime);
112 Blob body;
113 @ <!-- Forum post %d(id) -->
114 @ <table class="forum_post">
115 @ <tr>
116 @ <td class="forum_margin" width="%d(iDepth*25)" rowspan="2">
117 @ <td><span class="forum_author">%h(zUser)</span>
118 @ <span class="forum_age">%s(zAge) ago</span>
119 sqlite3_free(zAge);
120 if( g.perm.WrForum ){
121 @ <span class="forum_buttons">
@@ -167,11 +167,11 @@
167 style_footer();
168 }
169
170 /*
171 ** Use content in CGI parameters "s" (subject), "b" (body), and
172 ** "m" (mimetype) to create a new forum entry.
173 ** Return the id of the new forum entry.
174 **
175 ** If any problems occur, return 0 and set *pzErr to a description of
176 ** the problem.
177 **
@@ -183,11 +183,11 @@
183 */
184 static int forum_post(int itemId, int parentId, char **pzErr){
185 const char *zSubject = 0;
186 int threadId;
187 double rNow = db_double(0.0, "SELECT julianday('now')");
188 const char *zMime = wiki_filter_mimetypes(P("m"));
189 if( itemId==0 && parentId==0 ){
190 /* Start a new thread. Subject required. */
191 sqlite3_uint64 r1, r2;
192 zSubject = PT("s");
193 if( zSubject==0 || zSubject[0]==0 ){
@@ -196,11 +196,11 @@
196 }
197 sqlite3_randomness(sizeof(r1), &r1);
198 sqlite3_randomness(sizeof(r2), &r2);
199 db_multi_exec(
200 "INSERT INTO forumthread(mthreadhash, mtitle, mtime, npost)"
201 "VALUES(lower(hex(randomblob(32))),%Q,%!.17g,1)",
202 zSubject, rNow
203 );
204 threadId = db_last_insert_rowid();
205 }else{
206 threadId = db_int(0, "SELECT mthreadid FROM forumpost"
@@ -219,17 +219,17 @@
219 " mtime=%!.17g,"
220 " mimetype=%Q,"
221 " ipaddr=%Q,"
222 " mbody=%Q"
223 " WHERE mpostid=%d",
224 rNow, PT("m"), P("REMOTE_ADDR"), PT("b"), itemId
225 );
226 }else{
227 db_multi_exec(
228 "INSERT INTO forumpost(mposthash,mthreadid,uname,mtime,"
229 " mstatus,mimetype,ipaddr,inreplyto,mbody) VALUES"
230 " (lower(hex(randomblob(32))),%d,%Q,%!.17g,%Q,%Q,%Q,nullif(%d,0),%Q)",
231 threadId,g.zLogin,rNow,NULL,zMime,P("REMOTE_ADDR"),parentId,P("b"));
232 itemId = db_last_insert_rowid();
233 }
234 if( zSubject==0 ){
235 db_multi_exec(
@@ -275,25 +275,25 @@
275 if( itemId ){
276 cgi_redirectf("%R/forum?item=%d",itemId);
277 return;
278 }
279 }
280 if( itemId && (P("m")==0 || P("b")==0) ){
281 Stmt q;
282 db_prepare(&q, "SELECT mimetype, mbody FROM forumpost"
283 " WHERE mpostid=%d", itemId);
284 if( db_step(&q)==SQLITE_ROW ){
285 if( P("m")==0 ){
286 cgi_set_query_parameter("m", db_column_text(&q, 0));
287 }
288 if( P("b")==0 ){
289 cgi_set_query_parameter("b", db_column_text(&q, 1));
290 }
291 }
292 db_finalize(&q);
293 }
294 zMime = wiki_filter_mimetypes(P("m"));
295 if( itemId>0 ){
296 style_header("Edit Forum Post");
297 }else if( parentId>0 ){
298 style_header("Comment On Forum Post");
299 }else{
@@ -312,11 +312,11 @@
312 if( P("s") ){
313 @ <h1>%h(PT("s"))</h1>
314 }
315 @ <div class="forumpreviewbody">
316 blob_init(&x, PT("b"), -1);
317 wiki_render_by_mimetype(&x, PT("m"));
318 blob_reset(&x);
319 @ </div>
320 @ </div>
321 @ <hr>
322 }
323
--- src/forum.c
+++ src/forum.c
@@ -111,11 +111,11 @@
111 char *zAge = db_timespan_name(rNow - rMTime);
112 Blob body;
113 @ <!-- Forum post %d(id) -->
114 @ <table class="forum_post">
115 @ <tr>
116 @ <td class="forum_margin" width="%d(iDepth*40)" rowspan="2">
117 @ <td><span class="forum_author">%h(zUser)</span>
118 @ <span class="forum_age">%s(zAge) ago</span>
119 sqlite3_free(zAge);
120 if( g.perm.WrForum ){
121 @ <span class="forum_buttons">
@@ -167,11 +167,11 @@
167 style_footer();
168 }
169
170 /*
171 ** Use content in CGI parameters "s" (subject), "b" (body), and
172 ** "mimetype" (mimetype) to create a new forum entry.
173 ** Return the id of the new forum entry.
174 **
175 ** If any problems occur, return 0 and set *pzErr to a description of
176 ** the problem.
177 **
@@ -183,11 +183,11 @@
183 */
184 static int forum_post(int itemId, int parentId, char **pzErr){
185 const char *zSubject = 0;
186 int threadId;
187 double rNow = db_double(0.0, "SELECT julianday('now')");
188 const char *zMime = wiki_filter_mimetypes(P("mimetype"));
189 if( itemId==0 && parentId==0 ){
190 /* Start a new thread. Subject required. */
191 sqlite3_uint64 r1, r2;
192 zSubject = PT("s");
193 if( zSubject==0 || zSubject[0]==0 ){
@@ -196,11 +196,11 @@
196 }
197 sqlite3_randomness(sizeof(r1), &r1);
198 sqlite3_randomness(sizeof(r2), &r2);
199 db_multi_exec(
200 "INSERT INTO forumthread(mthreadhash, mtitle, mtime, npost)"
201 "VALUES(lower(hex(randomblob(28))),%Q,%!.17g,1)",
202 zSubject, rNow
203 );
204 threadId = db_last_insert_rowid();
205 }else{
206 threadId = db_int(0, "SELECT mthreadid FROM forumpost"
@@ -219,17 +219,17 @@
219 " mtime=%!.17g,"
220 " mimetype=%Q,"
221 " ipaddr=%Q,"
222 " mbody=%Q"
223 " WHERE mpostid=%d",
224 rNow, PT("mimetype"), P("REMOTE_ADDR"), PT("b"), itemId
225 );
226 }else{
227 db_multi_exec(
228 "INSERT INTO forumpost(mposthash,mthreadid,uname,mtime,"
229 " mstatus,mimetype,ipaddr,inreplyto,mbody) VALUES"
230 " (lower(hex(randomblob(28))),%d,%Q,%!.17g,%Q,%Q,%Q,nullif(%d,0),%Q)",
231 threadId,g.zLogin,rNow,NULL,zMime,P("REMOTE_ADDR"),parentId,P("b"));
232 itemId = db_last_insert_rowid();
233 }
234 if( zSubject==0 ){
235 db_multi_exec(
@@ -275,25 +275,25 @@
275 if( itemId ){
276 cgi_redirectf("%R/forum?item=%d",itemId);
277 return;
278 }
279 }
280 if( itemId && (P("mimetype")==0 || P("b")==0) ){
281 Stmt q;
282 db_prepare(&q, "SELECT mimetype, mbody FROM forumpost"
283 " WHERE mpostid=%d", itemId);
284 if( db_step(&q)==SQLITE_ROW ){
285 if( P("mimetype")==0 ){
286 cgi_set_query_parameter("mimetype", db_column_text(&q, 0));
287 }
288 if( P("b")==0 ){
289 cgi_set_query_parameter("b", db_column_text(&q, 1));
290 }
291 }
292 db_finalize(&q);
293 }
294 zMime = wiki_filter_mimetypes(P("mimetype"));
295 if( itemId>0 ){
296 style_header("Edit Forum Post");
297 }else if( parentId>0 ){
298 style_header("Comment On Forum Post");
299 }else{
@@ -312,11 +312,11 @@
312 if( P("s") ){
313 @ <h1>%h(PT("s"))</h1>
314 }
315 @ <div class="forumpreviewbody">
316 blob_init(&x, PT("b"), -1);
317 wiki_render_by_mimetype(&x, PT("mimetype"));
318 blob_reset(&x);
319 @ </div>
320 @ </div>
321 @ <hr>
322 }
323

Keyboard Shortcuts

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