Fossil

Check-in [b5e3bc9e41]
Login

Check-in [b5e3bc9e41]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Got basic /fileedit page skeleton in place. It can load/display a file, with some limits, but cannot yet do anything with it.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | checkin-without-checkout
Files: files | file ages | folders
SHA3-256: b5e3bc9e41127bbd1db145bad2bbb1a037f9ca159fe1cbbd1f2620341ae3d409
User & Date: stephan 2020-05-01 07:47:30.860
Context
2020-05-01
14:22
Initial work on /fileedit page. First dry-run save was just performed. ... (check-in: fbd31f2049 user: stephan tags: checkin-without-checkout)
07:47
Got basic /fileedit page skeleton in place. It can load/display a file, with some limits, but cannot yet do anything with it. ... (check-in: b5e3bc9e41 user: stephan tags: checkin-without-checkout)
07:33
Added quotes around the URLs passed to the browser for the ui command so that URL parameters containing an ampersand get passed on correctly. ... (check-in: 126d34fb32 user: stephan tags: checkin-without-checkout)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/checkin.c.
3487
3488
3489
3490
3491
3492
3493





































































































































  if(!(cinf.flags & CIMINI_DRY_RUN) && newRid!=0 && g.localOpen!=0){
    fossil_warning("The checkout state is now out of sync "
                   "with regards to this commit. It needs to be "
                   "'update'd or 'close'd and re-'open'ed.");
  }
  CheckinMiniInfo_cleanup(&cinf);
}












































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
  if(!(cinf.flags & CIMINI_DRY_RUN) && newRid!=0 && g.localOpen!=0){
    fossil_warning("The checkout state is now out of sync "
                   "with regards to this commit. It needs to be "
                   "'update'd or 'close'd and re-'open'ed.");
  }
  CheckinMiniInfo_cleanup(&cinf);
}


/*
** Returns true if the given filename qualified for online editing
** by the current user.
**
** Currently only looks at the user's permissions, pending decisions
** on whether we want to filter them based on a glob list or mimetype
** list.
*/
int file_is_online_editable(const char *zFilename){
  if(g.perm.Write){
    return 1;
  }
  return 0;    
}

/*
** WEBPAGE: fileedit
**
** EXPERIMENTAL and subject to change and removal at any time. The goal
** is to allow online edits of files.
**
** Query parameters:
**
**    file=FILE      Repo-relative path to the file.
**    r=VERSION      Checkin version
**
** Parameters intended to be passed in only via the editor's own form:
**
**    diff           If true, show diff from prev version.
**    preview        If true, preview (how depends on mimetype).
**    content        File content.
**    
**
*/
void fileedit_page(){
  const char * zFilename = PD("file",P("name")); /* filename */
  const char * zRev = P("r");           /* checkin version */
  const char * zContent = P("content"); /* file content */
  const char * zComment = P("comment"); /* checkin comment */
  char * zRevResolved = 0;              /* Resolved zRev */
  int vid, frid;                        /* checkin/file rids */
  char * zFileUuid = 0;
  Blob content = empty_blob;

  login_check_credentials();
  if( !g.perm.Write ){
    login_needed(g.anon.Write);
    return;
  }
  /*
  ** TODOs include, but are not limited to:
  **
  ** - On initial hit, fetch file content and stuff it in a textarea.
  **
  ** - Preview button + view
  **
  ** - Diff button + view
  **
  ** - Checkbox options: allow fork, dry-run, convert EOL,
  **   allow merge conflict, allow older (just in case server time
  **   is messed up or someone checked something in w/ a future
  **   timestamp)
  **
  */
  if(!zRev || !*zRev || !zFilename || !*zFilename){
    webpage_error("Missing required URL parameters.");
  }
  vid = symbolic_name_to_rid(zRev, "ci");
  if(0==vid){
    webpage_error("Could not resolve checkin version.");
  }
  zRevResolved = rid_to_uuid(vid);
  zFileUuid = db_text(0,"SELECT uuid FROM files_of_checkin WHERE "
                      "filename=%Q %s AND checkinID=%d",
                      zFilename, filename_collation(), vid);
  if(!zFileUuid){
    webpage_error("Checkin [%S] does not contain file: %T",
                  zRevResolved, zFilename);
  }

  frid = fast_uuid_to_rid(zFileUuid);
  assert(frid);
  if(zContent==0){
    content_get(frid, &content);
    zContent = blob_size(&content) ? blob_str(&content) : NULL;
  }else{
    blob_init(&content,zContent,-1);
  }
  if(looks_like_binary(&content)){
    webpage_error("File appears to be binary. Cannot edit: %T",
                  zFilename);
  }
  
  style_header("File Editor");
#define fp fossil_print
  /* ^^^ Appologies, Richard, but the @ form plays havoc with emacs */

  fp("<h1>Editing: %T</h1>",zFilename);
  fp("<p>This page is <em>far from complete</em>.</p>");
  
  fp("<form action=\"%R/fileedit\" method=\"POST\" class=\"fileedit-form\">");
  fp("<input type=\"hidden\" name=\"r\" value=\"%s\">", zRevResolved);
  fp("<input type=\"hidden\" name=\"file\" value=\"%T\">",
     zFilename);
  fp("<h3>Comment</h3>");
  fp("<textarea name=\"comment\" rows=\"3\" cols=\"80\">");
  if(zComment && *zComment){
    fp("%T"/*%T?*/, zComment);
  }
  fp("</textarea>");
  fp("<h3>Content</h3>");
  fp("<textarea name=\"content\" rows=\"20\" cols=\"80\">");
  if(zContent && *zContent){
    fp("%s", zContent);
  }
  fp("</textarea>");

  fp("<div class=\"fileedit-options\">");
  /* Put checkboxes here... */
  fp("Many buttons and checkboxes to put here");
  fp("</div>");  

  fp("</form>");
  
  blob_reset(&content);
  fossil_free(zRevResolved);
  fossil_free(zFileUuid);

  style_footer();
#undef fp
}
Changes to src/default_css.txt.
858
859
860
861
862
863
864









//   border: 1px solid black;
//   vertical-align: top;
// }
// #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
//   max-width: 30em;
//   overflow: auto;
// }
















>
>
>
>
>
>
>
>
>
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
//   border: 1px solid black;
//   vertical-align: top;
// }
// #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
//   max-width: 30em;
//   overflow: auto;
// }
// .fileedit-XXX => /fileedit page
.fileedit-form textarea {
  width: 100%;
}
.fileedit-form .fileedit-options {
  padding: 0.5em;
  margin: 1em 0 0 0;
  border: 2px inset #a0a0a0;
}