Fossil SCM

Add ability to upload unversioned files via the /uvlist page.

stephan 2024-06-25 18:10 trunk merge
Commit 2d4fd55fee5c4a142b7653de43673d4919249bbfd9e59512b24f722a1088d09f
--- src/main.mk
+++ src/main.mk
@@ -271,10 +271,11 @@
271271
$(SRCDIR)/sounds/f.wav \
272272
$(SRCDIR)/style.admin_log.css \
273273
$(SRCDIR)/style.chat.css \
274274
$(SRCDIR)/style.fileedit.css \
275275
$(SRCDIR)/style.pikchrshow.css \
276
+ $(SRCDIR)/style.uvlist.css \
276277
$(SRCDIR)/style.wikiedit.css \
277278
$(SRCDIR)/tree.js \
278279
$(SRCDIR)/useredit.js \
279280
$(SRCDIR)/wiki.wiki
280281
281282
282283
ADDED src/style.uvlist.css
--- src/main.mk
+++ src/main.mk
@@ -271,10 +271,11 @@
271 $(SRCDIR)/sounds/f.wav \
272 $(SRCDIR)/style.admin_log.css \
273 $(SRCDIR)/style.chat.css \
274 $(SRCDIR)/style.fileedit.css \
275 $(SRCDIR)/style.pikchrshow.css \
 
276 $(SRCDIR)/style.wikiedit.css \
277 $(SRCDIR)/tree.js \
278 $(SRCDIR)/useredit.js \
279 $(SRCDIR)/wiki.wiki
280
281
282 DDED src/style.uvlist.css
--- src/main.mk
+++ src/main.mk
@@ -271,10 +271,11 @@
271 $(SRCDIR)/sounds/f.wav \
272 $(SRCDIR)/style.admin_log.css \
273 $(SRCDIR)/style.chat.css \
274 $(SRCDIR)/style.fileedit.css \
275 $(SRCDIR)/style.pikchrshow.css \
276 $(SRCDIR)/style.uvlist.css \
277 $(SRCDIR)/style.wikiedit.css \
278 $(SRCDIR)/tree.js \
279 $(SRCDIR)/useredit.js \
280 $(SRCDIR)/wiki.wiki
281
282
283 DDED src/style.uvlist.css
--- a/src/style.uvlist.css
+++ b/src/style.uvlist.css
@@ -0,0 +1,7 @@
1
+body.uvlist input {
2
+ margin: 0.5em;
3
+}
4
+
5
+body.uvlist form {
6
+ display: block;
7
+}
--- a/src/style.uvlist.css
+++ b/src/style.uvlist.css
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
--- a/src/style.uvlist.css
+++ b/src/style.uvlist.css
@@ -0,0 +1,7 @@
1 body.uvlist input {
2 margin: 0.5em;
3 }
4
5 body.uvlist form {
6 display: block;
7 }
--- src/unversioned.c
+++ src/unversioned.c
@@ -520,10 +520,56 @@
520520
db_end_transaction(0);
521521
}else{
522522
usage("add|cat|edit|export|list|revert|remove|sync|touch");
523523
}
524524
}
525
+
526
+/*
527
+** Emit an HTML form for uploading a new unversioned file if
528
+** the current user has WrUnver permissions, else this is
529
+** a no-op.
530
+**
531
+** If this function detects that the form it emits has been submitted,
532
+** it will add the uploaded file to the unversioned file list before
533
+** returning.
534
+**
535
+** Intended only for use by /uvlist, and its form's action is that
536
+** page.
537
+*/
538
+static void uvlist_upload(void){
539
+ const char * aContent;
540
+ if( !g.perm.WrUnver ) return;
541
+ aContent = P("f");
542
+ if( aContent!=0 ){
543
+ const char * const zName = P("f:filename");
544
+ int const nContent = atoi(PD("f:bytes","0"));
545
+ const char * zError = 0;
546
+ Blob content;
547
+ if( zName[0]==0 ){
548
+ zError = "be an empty string";
549
+ }else if( contains_whitespace(zName) ){
550
+ zError = "contain spaces";
551
+ }
552
+ if( zError ){
553
+ fossil_fatal("Unversioned filenames may not %s: %Q",
554
+ zError, zName);
555
+ }
556
+ unversioned_schema();
557
+ db_begin_transaction();
558
+ content_rcvid_init("#!fossil /uvlist upload");
559
+ blob_init(&content, aContent, nContent);
560
+ unversioned_write(zName, &content, time(0));
561
+ blob_reset(&content);
562
+ db_end_transaction(0);
563
+ CX("<div>Added: %s</div>", zName);
564
+ }
565
+ form_begin("enctype='multipart/form-data'", "%R/uvlist");
566
+ CX("<label for='uvupload'>Upload unversioned file:</label>");
567
+ CX("<input type='file' id='uvupload' name='f'/>");
568
+ CX("<input type='submit' value='Upload'/>");
569
+ CX("</form>");
570
+}
525571
526572
/*
527573
** WEBPAGE: uvlist
528574
**
529575
** Display a list of all unversioned files in the repository.
@@ -545,10 +591,11 @@
545591
login_check_credentials();
546592
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
547593
cgi_check_for_malice();
548594
etag_check(ETAG_DATA,0);
549595
style_header("Unversioned Files");
596
+ uvlist_upload();
550597
if( !db_table_exists("repository","unversioned") ){
551598
@ No unversioned files on this server
552599
style_finish_page();
553600
return;
554601
}
555602
--- src/unversioned.c
+++ src/unversioned.c
@@ -520,10 +520,56 @@
520 db_end_transaction(0);
521 }else{
522 usage("add|cat|edit|export|list|revert|remove|sync|touch");
523 }
524 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
526 /*
527 ** WEBPAGE: uvlist
528 **
529 ** Display a list of all unversioned files in the repository.
@@ -545,10 +591,11 @@
545 login_check_credentials();
546 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
547 cgi_check_for_malice();
548 etag_check(ETAG_DATA,0);
549 style_header("Unversioned Files");
 
550 if( !db_table_exists("repository","unversioned") ){
551 @ No unversioned files on this server
552 style_finish_page();
553 return;
554 }
555
--- src/unversioned.c
+++ src/unversioned.c
@@ -520,10 +520,56 @@
520 db_end_transaction(0);
521 }else{
522 usage("add|cat|edit|export|list|revert|remove|sync|touch");
523 }
524 }
525
526 /*
527 ** Emit an HTML form for uploading a new unversioned file if
528 ** the current user has WrUnver permissions, else this is
529 ** a no-op.
530 **
531 ** If this function detects that the form it emits has been submitted,
532 ** it will add the uploaded file to the unversioned file list before
533 ** returning.
534 **
535 ** Intended only for use by /uvlist, and its form's action is that
536 ** page.
537 */
538 static void uvlist_upload(void){
539 const char * aContent;
540 if( !g.perm.WrUnver ) return;
541 aContent = P("f");
542 if( aContent!=0 ){
543 const char * const zName = P("f:filename");
544 int const nContent = atoi(PD("f:bytes","0"));
545 const char * zError = 0;
546 Blob content;
547 if( zName[0]==0 ){
548 zError = "be an empty string";
549 }else if( contains_whitespace(zName) ){
550 zError = "contain spaces";
551 }
552 if( zError ){
553 fossil_fatal("Unversioned filenames may not %s: %Q",
554 zError, zName);
555 }
556 unversioned_schema();
557 db_begin_transaction();
558 content_rcvid_init("#!fossil /uvlist upload");
559 blob_init(&content, aContent, nContent);
560 unversioned_write(zName, &content, time(0));
561 blob_reset(&content);
562 db_end_transaction(0);
563 CX("<div>Added: %s</div>", zName);
564 }
565 form_begin("enctype='multipart/form-data'", "%R/uvlist");
566 CX("<label for='uvupload'>Upload unversioned file:</label>");
567 CX("<input type='file' id='uvupload' name='f'/>");
568 CX("<input type='submit' value='Upload'/>");
569 CX("</form>");
570 }
571
572 /*
573 ** WEBPAGE: uvlist
574 **
575 ** Display a list of all unversioned files in the repository.
@@ -545,10 +591,11 @@
591 login_check_credentials();
592 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
593 cgi_check_for_malice();
594 etag_check(ETAG_DATA,0);
595 style_header("Unversioned Files");
596 uvlist_upload();
597 if( !db_table_exists("repository","unversioned") ){
598 @ No unversioned files on this server
599 style_finish_page();
600 return;
601 }
602
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -657,10 +657,11 @@
657657
$(SRCDIR)/sounds/f.wav \
658658
$(SRCDIR)/style.admin_log.css \
659659
$(SRCDIR)/style.chat.css \
660660
$(SRCDIR)/style.fileedit.css \
661661
$(SRCDIR)/style.pikchrshow.css \
662
+ $(SRCDIR)/style.uvlist.css \
662663
$(SRCDIR)/style.wikiedit.css \
663664
$(SRCDIR)/tree.js \
664665
$(SRCDIR)/useredit.js \
665666
$(SRCDIR)/wiki.wiki
666667
667668
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -657,10 +657,11 @@
657 $(SRCDIR)/sounds/f.wav \
658 $(SRCDIR)/style.admin_log.css \
659 $(SRCDIR)/style.chat.css \
660 $(SRCDIR)/style.fileedit.css \
661 $(SRCDIR)/style.pikchrshow.css \
 
662 $(SRCDIR)/style.wikiedit.css \
663 $(SRCDIR)/tree.js \
664 $(SRCDIR)/useredit.js \
665 $(SRCDIR)/wiki.wiki
666
667
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -657,10 +657,11 @@
657 $(SRCDIR)/sounds/f.wav \
658 $(SRCDIR)/style.admin_log.css \
659 $(SRCDIR)/style.chat.css \
660 $(SRCDIR)/style.fileedit.css \
661 $(SRCDIR)/style.pikchrshow.css \
662 $(SRCDIR)/style.uvlist.css \
663 $(SRCDIR)/style.wikiedit.css \
664 $(SRCDIR)/tree.js \
665 $(SRCDIR)/useredit.js \
666 $(SRCDIR)/wiki.wiki
667
668
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -615,10 +615,11 @@
615615
"$(SRCDIR)\sounds\f.wav" \
616616
"$(SRCDIR)\style.admin_log.css" \
617617
"$(SRCDIR)\style.chat.css" \
618618
"$(SRCDIR)\style.fileedit.css" \
619619
"$(SRCDIR)\style.pikchrshow.css" \
620
+ "$(SRCDIR)\style.uvlist.css" \
620621
"$(SRCDIR)\style.wikiedit.css" \
621622
"$(SRCDIR)\tree.js" \
622623
"$(SRCDIR)\useredit.js" \
623624
"$(SRCDIR)\wiki.wiki"
624625
@@ -1244,10 +1245,11 @@
12441245
echo "$(SRCDIR)\sounds/f.wav" >> $@
12451246
echo "$(SRCDIR)\style.admin_log.css" >> $@
12461247
echo "$(SRCDIR)\style.chat.css" >> $@
12471248
echo "$(SRCDIR)\style.fileedit.css" >> $@
12481249
echo "$(SRCDIR)\style.pikchrshow.css" >> $@
1250
+ echo "$(SRCDIR)\style.uvlist.css" >> $@
12491251
echo "$(SRCDIR)\style.wikiedit.css" >> $@
12501252
echo "$(SRCDIR)\tree.js" >> $@
12511253
echo "$(SRCDIR)\useredit.js" >> $@
12521254
echo "$(SRCDIR)\wiki.wiki" >> $@
12531255
12541256
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -615,10 +615,11 @@
615 "$(SRCDIR)\sounds\f.wav" \
616 "$(SRCDIR)\style.admin_log.css" \
617 "$(SRCDIR)\style.chat.css" \
618 "$(SRCDIR)\style.fileedit.css" \
619 "$(SRCDIR)\style.pikchrshow.css" \
 
620 "$(SRCDIR)\style.wikiedit.css" \
621 "$(SRCDIR)\tree.js" \
622 "$(SRCDIR)\useredit.js" \
623 "$(SRCDIR)\wiki.wiki"
624
@@ -1244,10 +1245,11 @@
1244 echo "$(SRCDIR)\sounds/f.wav" >> $@
1245 echo "$(SRCDIR)\style.admin_log.css" >> $@
1246 echo "$(SRCDIR)\style.chat.css" >> $@
1247 echo "$(SRCDIR)\style.fileedit.css" >> $@
1248 echo "$(SRCDIR)\style.pikchrshow.css" >> $@
 
1249 echo "$(SRCDIR)\style.wikiedit.css" >> $@
1250 echo "$(SRCDIR)\tree.js" >> $@
1251 echo "$(SRCDIR)\useredit.js" >> $@
1252 echo "$(SRCDIR)\wiki.wiki" >> $@
1253
1254
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -615,10 +615,11 @@
615 "$(SRCDIR)\sounds\f.wav" \
616 "$(SRCDIR)\style.admin_log.css" \
617 "$(SRCDIR)\style.chat.css" \
618 "$(SRCDIR)\style.fileedit.css" \
619 "$(SRCDIR)\style.pikchrshow.css" \
620 "$(SRCDIR)\style.uvlist.css" \
621 "$(SRCDIR)\style.wikiedit.css" \
622 "$(SRCDIR)\tree.js" \
623 "$(SRCDIR)\useredit.js" \
624 "$(SRCDIR)\wiki.wiki"
625
@@ -1244,10 +1245,11 @@
1245 echo "$(SRCDIR)\sounds/f.wav" >> $@
1246 echo "$(SRCDIR)\style.admin_log.css" >> $@
1247 echo "$(SRCDIR)\style.chat.css" >> $@
1248 echo "$(SRCDIR)\style.fileedit.css" >> $@
1249 echo "$(SRCDIR)\style.pikchrshow.css" >> $@
1250 echo "$(SRCDIR)\style.uvlist.css" >> $@
1251 echo "$(SRCDIR)\style.wikiedit.css" >> $@
1252 echo "$(SRCDIR)\tree.js" >> $@
1253 echo "$(SRCDIR)\useredit.js" >> $@
1254 echo "$(SRCDIR)\wiki.wiki" >> $@
1255
1256
--- www/changes.wiki
+++ www/changes.wiki
@@ -11,11 +11,12 @@
1111
which is more familiar to Git users. Retain the legacy name for
1212
compatibility.
1313
* Add new query parameters to the [/help?cmd=/timeline|/timeline page]:
1414
d2=, p2=, and dp2=.
1515
* Add options to the [/help?cmd=tag|fossil tag] command that will list tag values
16
-
16
+ * Add ability to upload unversioned files via the [/help?cmd=/uvlist|/uvlist page].
17
+
1718
1819
<h2 id='v2_24'>Changes for version 2.24 (2024-04-23)</h2>
1920
2021
* Apache change work-around &rarr; As part of a security fix, the Apache webserver
2122
mod_cgi module has stopped relaying the Content-Length field of the HTTP
2223
--- www/changes.wiki
+++ www/changes.wiki
@@ -11,11 +11,12 @@
11 which is more familiar to Git users. Retain the legacy name for
12 compatibility.
13 * Add new query parameters to the [/help?cmd=/timeline|/timeline page]:
14 d2=, p2=, and dp2=.
15 * Add options to the [/help?cmd=tag|fossil tag] command that will list tag values
16
 
17
18 <h2 id='v2_24'>Changes for version 2.24 (2024-04-23)</h2>
19
20 * Apache change work-around &rarr; As part of a security fix, the Apache webserver
21 mod_cgi module has stopped relaying the Content-Length field of the HTTP
22
--- www/changes.wiki
+++ www/changes.wiki
@@ -11,11 +11,12 @@
11 which is more familiar to Git users. Retain the legacy name for
12 compatibility.
13 * Add new query parameters to the [/help?cmd=/timeline|/timeline page]:
14 d2=, p2=, and dp2=.
15 * Add options to the [/help?cmd=tag|fossil tag] command that will list tag values
16 * Add ability to upload unversioned files via the [/help?cmd=/uvlist|/uvlist page].
17
18
19 <h2 id='v2_24'>Changes for version 2.24 (2024-04-23)</h2>
20
21 * Apache change work-around &rarr; As part of a security fix, the Apache webserver
22 mod_cgi module has stopped relaying the Content-Length field of the HTTP
23

Keyboard Shortcuts

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