| ︙ | | |
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
|
-
+
+
+
|
if(0==fossil_strcmp(zFilePrev->zUuid, blob_str(&pCI->fileHash))
&& manifest_file_mperm(zFilePrev)==pCI->filePerm){
ci_err((pErr,"File is unchanged. Not saving."));
}
}
#if 1
/* Do we really want to normalize comment EOLs? Web-posting will
** submit them in CRLF format. */
** submit them in CRLF or LF format, depending on how exactly the
** content is submitted (FORM (CRLF) or textarea-to-POST (LF, at
** least in theory)). */
blob_to_lf_only(&pCI->comment);
#endif
/* Create, save, deltify, and crosslink the manifest... */
if(create_manifest_mini(&mf, pCI, pErr)==0){
return 0;
}
isPrivate = content_is_private(pCI->pParent->rid);
|
| ︙ | | |
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
|
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
|
-
+
+
+
|
}
if(p_int("allow_fork")!=0){
p->flags |= CIMINI_ALLOW_FORK;
}
if(p_int("allow_older")!=0){
p->flags |= CIMINI_ALLOW_OLDER;
}
if(p_int("exec_bit")!=0){
if(0==p_int("exec_bit")){
p->filePerm = PERM_REG;
}else{
p->filePerm = PERM_EXE;
}
if(p_int("allow_merge_conflict")!=0){
p->flags |= CIMINI_ALLOW_MERGE_MARKER;
}
if(p_int("prefer_delta")!=0){
p->flags |= CIMINI_PREFER_DELTA;
|
| ︙ | | |
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
|
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
|
-
+
+
+
-
-
-
+
+
+
+
+
+
+
|
**
** comment_mimetype=text
** dry_run=int (1 or 0)
**
**
** User must have Write access to use this page.
**
** Responds with JSON:
** Responds with JSON (with some state repeated
** from the input in order to avoid certain race conditions
** client-side):
**
** {
** uuid: newUUID,
** manifest: text of manifest,
** dryRun: bool
** checkin: newUUID,
** filename: theFilename,
** mimetype: string,
** isExe: bool,
** dryRun: bool,
** manifest: text of manifest,
** }
**
** On error it produces a JSON response as documented for
** fileedit_ajax_error().
*/
static void fileedit_ajax_commit(void){
Blob err = empty_blob; /* Error messages */
Blob manifest = empty_blob; /* raw new manifest */
CheckinMiniInfo cimi; /* checkin state */
int rc; /* generic result code */
int newVid = 0; /* new version's RID */
char * zNewUuid = 0; /* newVid's UUID */
char const * zMimetype;
if(!fileedit_ajax_boostrap()){
return;
}
db_begin_transaction();
CheckinMiniInfo_init(&cimi);
rc = fileedit_setup_cimi_from_p(&cimi, &err, 0);
|
| ︙ | | |
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
|
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
|
-
+
+
+
+
+
+
+
|
fileedit_ajax_error(500,"%b",&err);
goto end_cleanup;
}
assert(newVid>0);
zNewUuid = rid_to_uuid(newVid);
cgi_set_content_type("application/json");
CX("{");
CX("\"uuid\":%!j,", zNewUuid);
CX("\"checkin\":%!j,", zNewUuid);
CX("\"filename\":%!j,", cimi.zFilename);
CX("\"isExe\": %s,", cimi.filePerm==PERM_EXE ? "true" : "false");
zMimetype = mimetype_from_name(cimi.zFilename);
if(zMimetype!=0){
CX("\"mimetype\": %!j,", zMimetype);
}
CX("\"dryRun\": %s,",
(CIMINI_DRY_RUN & cimi.flags) ? "true" : "false");
CX("\"manifest\": %!j", blob_str(&manifest));
CX("}");
db_end_transaction(0/*noting that dry-run mode will have already
** set this to rollback mode. */);
end_cleanup:
|
| ︙ | | |
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
|
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
|
-
+
-
|
"editor_font_size", "Editor font size",
NULL/*tooltip*/,
100,
"100%", 100, "125%", 125,
"150%", 150, "175%", 175,
"200%", 200, NULL);
CX("</div>");
CX("<div class='flex-container flex-row'>");
CX("<div class='flex-container flex-column'>");
CX("<textarea name='content' id='fileedit-content-editor' "
"class='fileedit' "
"rows='20' cols='80'>");
CX("Loading...");
CX("</textarea>");
CX("</div>"/*textarea wrapper*/);
CX("</div>"/*#tab-file-content*/);
}
/****** Preview tab ******/
{
|
| ︙ | | |
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
|
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
|
+
+
+
+
+
+
+
|
CX("<li>\"Delta manifests\" (see the checkbox on the Commit tab) "
"make for smaller commit records, especially in repositories "
"with many files.</li>");
CX("<li>The file selector allows, for usability's sake, only files "
"in leaf checkins to be selected, but files may be edited via "
"non-leaf checkins by passing them as the <code>filename</code> "
"and <code>checkin</code> URL arguments to this page.</li>");
CX("<li>The editor \"stashes\" local edits to the last 7 "
"checkin/file combinations in one of "
"<code>window.fileStorage</code> or "
"<code>window.sessionStorage</code>, if able, but which storage "
"is unspecified and may differ across environments. When saving "
"or force-reloading a file, stashed edits to that version are "
"discarded.</li>");
CX("</ul>");
}
CX("</div>"/*#fileedit-tab-help*/);
{
/* Dynamically populate the editor, display any error in the err
** blob, and/or switch to tab #0, where the file selector
|
| ︙ | | |
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
|
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
|
+
|
blob_reset(&err);
CheckinMiniInfo_cleanup(&cimi);
style_emit_script_fossil_bootstrap(0);
append_diff_javascript(1);
style_emit_script_fetch(0);
style_emit_script_tabs(0)/*also emits fossil.dom*/;
style_emit_script_confirmer(0);
style_emit_script_builtin(0, "fossil.storage.js");
style_emit_script_builtin(0, "fossil.page.fileedit.js");
if(blob_size(&endScript)>0){
style_emit_script_tag(0,0);
CX("(function(){\n");
CX("try{\n%b\n}"
"catch(e){"
"fossil.error(e);\n"
|
| ︙ | | |