Collection of themes/skins for the Fossil SCM

⌈⌋ ⎇ branch:  Fossil Skins Extra


Hex Artifact Content

Artifact 78780cb7657216ba9dd7bc82517e092dc675ecb4:

  • File features/file_link.th1 — part of check-in [9c6bfdeb8a] at 2021-10-20 05:56:53 on branch trunk — Support for real doc/trunk/file.txt browsing (user: mario size: 1756)

0000: 23 20 6f 75 74 70 75 74 20 3c 6c 69 6e 6b 3e 20  # output <link> 
0010: 66 6f 72 20 22 66 69 6c 65 22 20 70 61 67 65 73  for "file" pages
0020: 0a 70 72 6f 63 20 66 69 6c 65 5f 6c 69 6e 6b 20  .proc file_link 
0030: 7b 7d 20 7b 0a 20 20 20 20 75 70 76 61 72 20 31  {} {.    upvar 1
0040: 20 63 75 72 72 65 6e 74 5f 70 61 67 65 20 63 75   current_page cu
0050: 72 72 65 6e 74 5f 70 61 67 65 0a 20 20 20 20 73  rrent_page.    s
0060: 65 74 20 6e 61 6d 65 20 5b 67 65 74 50 61 72 61  et name [getPara
0070: 6d 65 74 65 72 20 6e 61 6d 65 5d 0a 20 20 20 20  meter name].    
0080: 73 65 74 20 63 69 20 5b 67 65 74 50 61 72 61 6d  set ci [getParam
0090: 65 74 65 72 20 63 69 5d 25 0a 20 20 20 20 73 65  eter ci]%.    se
00a0: 74 20 73 71 6c 5f 62 79 6e 61 6d 65 63 69 20 7b  t sql_bynameci {
00b0: 0a 20 20 20 20 20 20 53 45 4c 45 43 54 20 62 5f  .      SELECT b_
00c0: 61 72 74 69 66 61 63 74 2e 75 75 69 64 20 41 53  artifact.uuid AS
00d0: 20 75 75 69 64 0a 20 20 20 20 20 20 20 20 46 52   uuid.        FR
00e0: 4f 4d 20 62 6c 6f 62 20 62 5f 63 68 65 63 6b 69  OM blob b_checki
00f0: 6e 20 4c 45 46 54 20 4a 4f 49 4e 20 6d 6c 69 6e  n LEFT JOIN mlin
0100: 6b 20 4f 4e 20 6d 69 64 3d 62 5f 63 68 65 63 6b  k ON mid=b_check
0110: 69 6e 2e 72 69 64 0a 20 20 20 20 20 20 20 20 4c  in.rid.        L
0120: 45 46 54 20 4a 4f 49 4e 20 66 69 6c 65 6e 61 6d  EFT JOIN filenam
0130: 65 20 6f 6e 20 6d 6c 69 6e 6b 2e 66 6e 69 64 3d  e on mlink.fnid=
0140: 66 69 6c 65 6e 61 6d 65 2e 66 6e 69 64 0a 20 20  filename.fnid.  
0150: 20 20 20 20 20 20 4c 45 46 54 20 4a 4f 49 4e 20        LEFT JOIN 
0160: 62 6c 6f 62 20 62 5f 61 72 74 69 66 61 63 74 20  blob b_artifact 
0170: 4f 4e 20 6d 6c 69 6e 6b 2e 66 69 64 3d 62 5f 61  ON mlink.fid=b_a
0180: 72 74 69 66 61 63 74 2e 72 69 64 0a 20 20 20 20  rtifact.rid.    
0190: 20 20 20 57 48 45 52 45 20 62 5f 63 68 65 63 6b     WHERE b_check
01a0: 69 6e 2e 75 75 69 64 20 4c 49 4b 45 20 24 63 69  in.uuid LIKE $ci
01b0: 20 41 4e 44 20 6e 61 6d 65 20 3d 20 24 6e 61 6d   AND name = $nam
01c0: 65 0a 20 20 20 20 20 20 20 4f 52 44 45 52 20 42  e.       ORDER B
01d0: 59 20 62 5f 61 72 74 69 66 61 63 74 2e 72 69 64  Y b_artifact.rid
01e0: 20 44 45 53 43 0a 20 20 20 20 7d 0a 20 20 20 20   DESC.    }.    
01f0: 23 68 74 6d 6c 20 22 3c 21 2d 2d 20 46 4c 28 24  #html "<!-- FL($
0200: 63 75 72 72 65 6e 74 5f 70 61 67 65 2c 6e 61 6d  current_page,nam
0210: 65 3d 24 6e 61 6d 65 2c 63 69 3d 24 63 69 29 20  e=$name,ci=$ci) 
0220: 2d 2d 3e 5c 6e 22 0a 20 20 20 20 69 66 20 7b 5b  -->\n".    if {[
0230: 72 65 67 65 78 70 20 20 22 5e 64 6f 63 2f 28 74  regexp  "^doc/(t
0240: 69 70 7c 74 72 75 6e 6b 29 2f 2e 2b 22 20 24 63  ip|trunk)/.+" $c
0250: 75 72 72 65 6e 74 5f 70 61 67 65 5d 7d 20 7b 0a  urrent_page]} {.
0260: 20 20 20 20 20 20 20 20 23 20 64 6f 63 2f 74 69          # doc/ti
0270: 70 2f 66 69 6c 65 2e 74 78 74 20 28 73 61 6d 65  p/file.txt (same
0280: 20 66 6f 72 20 64 6f 63 2f 20 61 63 63 65 73 73   for doc/ access
0290: 20 61 6e 64 20 66 69 6c 65 3f 6e 61 6d 65 3d 66   and file?name=f
02a0: 6e 2e 74 78 74 20 62 72 6f 77 73 69 6e 67 29 0a  n.txt browsing).
02b0: 20 20 20 20 20 20 20 20 73 65 74 20 73 71 6c 20          set sql 
02c0: 22 24 73 71 6c 5f 62 79 6e 61 6d 65 63 69 20 4c  "$sql_bynameci L
02d0: 49 4d 49 54 20 31 22 0a 20 20 20 20 20 20 20 20  IMIT 1".        
02e0: 69 66 20 7b 5b 72 65 67 65 78 70 20 20 22 5e 28  if {[regexp  "^(
02f0: 74 69 70 2f 29 22 20 24 6e 61 6d 65 5d 7d 20 7b  tip/)" $name]} {
0300: 20 73 65 74 20 6e 61 6d 65 20 5b 73 74 72 69 6e   set name [strin
0310: 67 20 72 61 6e 67 65 20 24 6e 61 6d 65 20 34 20  g range $name 4 
0320: 32 30 30 5d 20 7d 0a 20 20 20 20 20 20 20 20 69  200] }.        i
0330: 66 20 7b 5b 72 65 67 65 78 70 20 20 22 5e 28 74  f {[regexp  "^(t
0340: 72 75 6e 6b 2f 29 22 20 24 6e 61 6d 65 5d 7d 20  runk/)" $name]} 
0350: 7b 20 73 65 74 20 6e 61 6d 65 20 5b 73 74 72 69  { set name [stri
0360: 6e 67 20 72 61 6e 67 65 20 24 6e 61 6d 65 20 36  ng range $name 6
0370: 20 32 30 30 5d 20 7d 0a 20 20 20 20 7d 20 65 6c   200] }.    } el
0380: 73 65 69 66 20 7b 22 24 63 75 72 72 65 6e 74 5f  seif {"$current_
0390: 70 61 67 65 22 20 65 71 20 22 66 69 6e 66 6f 22  page" eq "finfo"
03a0: 7d 20 7b 0a 20 20 20 20 20 20 20 20 69 66 20 7b  } {.        if {
03b0: 22 24 63 69 22 20 6e 65 20 22 25 22 7d 20 7b 0a  "$ci" ne "%"} {.
03c0: 20 20 20 20 20 20 20 20 20 20 20 20 23 20 66 69              # fi
03d0: 6e 66 6f 3f 6e 61 6d 65 3d 66 69 6c 65 2e 74 78  nfo?name=file.tx
03e0: 74 26 63 69 3d 31 32 33 34 66 0a 20 20 20 20 20  t&ci=1234f.     
03f0: 20 20 20 20 20 20 20 73 65 74 20 73 71 6c 20 24         set sql $
0400: 73 71 6c 5f 62 79 6e 61 6d 65 63 69 0a 20 20 20  sql_bynameci.   
0410: 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20       } else {.  
0420: 20 20 20 20 20 20 20 20 20 20 23 20 66 69 6e 66            # finf
0430: 6f 3f 6e 61 6d 65 3d 66 69 6c 65 2e 74 78 74 0a  o?name=file.txt.
0440: 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 20              set 
0450: 73 71 6c 20 22 24 73 71 6c 5f 62 79 6e 61 6d 65  sql "$sql_byname
0460: 63 69 20 4c 49 4d 49 54 20 31 22 0a 20 20 20 20  ci LIMIT 1".    
0470: 20 20 20 20 7d 0a 20 20 20 20 7d 20 65 6c 73 65      }.    } else
0480: 69 66 20 7b 5b 72 65 67 65 78 70 20 20 22 5e 64  if {[regexp  "^d
0490: 6f 63 2f 5c 5c 77 2b 2f 2e 2b 22 20 24 63 75 72  oc/\\w+/.+" $cur
04a0: 72 65 6e 74 5f 70 61 67 65 5d 7d 20 7b 0a 20 20  rent_page]} {.  
04b0: 20 20 20 20 20 20 69 66 20 7b 22 24 63 69 22 20        if {"$ci" 
04c0: 6e 65 20 22 25 22 7d 20 7b 0a 20 20 20 20 20 20  ne "%"} {.      
04d0: 20 20 20 20 20 20 23 20 64 6f 63 2f 31 32 33 34        # doc/1234
04e0: 66 2f 66 69 6c 65 2e 74 78 74 0a 20 20 20 20 20  f/file.txt.     
04f0: 20 20 20 20 20 20 20 73 65 74 20 73 71 6c 20 24         set sql $
0500: 73 71 6c 5f 62 79 6e 61 6d 65 63 69 0a 20 20 20  sql_bynameci.   
0510: 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20       } else {.  
0520: 20 20 20 20 20 20 20 20 20 20 23 20 2f 69 6e 66            # /inf
0530: 6f 2f 31 32 33 34 66 20 20 23 20 73 68 6f 75 6c  o/1234f  # shoul
0540: 64 20 61 73 73 65 72 74 20 74 68 61 74 20 69 74  d assert that it
0550: 20 72 65 66 65 72 73 20 74 6f 20 61 20 66 69 6c   refers to a fil
0560: 65 20 62 6c 6f 62 3f 0a 20 20 20 20 20 20 20 20  e blob?.        
0570: 20 20 20 20 73 65 74 20 6e 61 6d 65 20 22 24 6e      set name "$n
0580: 61 6d 65 25 22 0a 20 20 20 20 20 20 20 20 20 20  ame%".          
0590: 20 20 73 65 74 20 73 71 6c 20 7b 53 45 4c 45 43    set sql {SELEC
05a0: 54 20 75 75 69 64 20 46 52 4f 4d 20 62 6c 6f 62  T uuid FROM blob
05b0: 20 77 68 65 72 65 20 75 75 69 64 20 4c 49 4b 45   where uuid LIKE
05c0: 20 24 6e 61 6d 65 7d 0a 20 20 20 20 20 20 20 20   $name}.        
05d0: 7d 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20  }.    } else {. 
05e0: 20 20 20 20 20 20 20 23 68 74 6d 6c 20 22 3c 21         #html "<!
05f0: 2d 2d 6e 6f 63 61 73 65 6d 61 74 63 68 2d 2d 3e  --nocasematch-->
0600: 22 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 7b  ".    }.    if {
0610: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 73 71 6c  [info exists sql
0620: 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 68 74  ]} {.        #ht
0630: 6d 6c 20 22 3c 21 2d 2d 20 3d 20 24 73 71 6c 20  ml "<!-- = $sql 
0640: 2d 2d 3e 22 0a 20 20 20 20 20 20 20 20 73 65 74  -->".        set
0650: 20 74 6f 70 20 5b 67 6c 6f 62 61 6c 53 74 61 74   top [globalStat
0660: 65 20 74 6f 70 5d 0a 20 20 20 20 20 20 20 20 71  e top].        q
0670: 75 65 72 79 20 24 73 71 6c 20 7b 0a 20 20 20 20  uery $sql {.    
0680: 20 20 20 20 20 20 20 20 68 74 6d 6c 20 22 3c 6c          html "<l
0690: 69 6e 6b 20 72 65 6c 3d 5c 22 61 6c 74 65 72 6e  ink rel=\"altern
06a0: 61 74 69 76 65 20 76 63 73 20 72 61 77 5c 22 20  ative vcs raw\" 
06b0: 68 72 65 66 3d 5c 22 24 74 6f 70 2f 72 61 77 2f  href=\"$top/raw/
06c0: 24 75 75 69 64 5c 22 3e 22 0a 20 20 20 20 20 20  $uuid\">".      
06d0: 20 20 7d 0a 20 20 20 20 7d 0a 7d 0a                }.    }.}.