Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
7.7 KiB

  1. NAME
  2. display - script to display fragments of text on the web and elsewhere
  3. DESCRIPTION
  4. display started life as a way to concatenate fragments of handwritten
  5. HTML by date. While the script has since haphazardly accumulated several
  6. of the usual weblog features (comments, lightweight markup, feed
  7. generation, embedded Perl, poetry tools, stupid dependencies), it hasn't
  8. changed much in six years. The current version is intended to support
  9. FastCGI via CGI::Fast, if available, and otherwise operate as a
  10. traditional CGI or commandline utility. It may have some distance to go
  11. towards this goal.
  12. Entries are stored in a simple directory tree under
  13. $DISPLAY_CONF{ROOT_DIR}.
  14. Like:
  15. archives/2001/1/1
  16. archives/2001/1/1/sub_entry
  17. An entry may be either a plain text file, or a directory containing
  18. several such files + whatever else you'd like to store. If it's a
  19. directory, the file called "index" will be treated as the text of the
  20. entry, and all other lower case filenames without extensions will be
  21. treated as sub-entries or documents within that entry, and displayed
  22. accordingly.
  23. Directories may be nested to an arbitrary depth, though I don't promise
  24. that this won't break on you.
  25. A PNG or JPEG file with a name like
  26. 2001/1/1.icon.png
  27. 2001/1/1/index.icon.png
  28. 2001/1/1/whatever.icon.png
  29. will be treated as an icon for the appropriate entry file.
  30. MARKUP
  31. Entries may consist of hand-written HTML (to be passed along without
  32. further interpretation), a supported form of lightweight markup, or some
  33. combination thereof. Actually, an entry may consist of any darn thing
  34. you please, as long as Perl will agree that it is text, but presumably
  35. you're going to be feeding this to a browser.
  36. Special markup is indicated by a variety of XML-style container tags.
  37. Embedded Perl - evaluated and replaced by whatever value you return
  38. (evaluated in a scalar context):
  39. <perl>my $dog = "Ralph."; return $dog;</perl>
  40. This code is evaluated before any other processing is done, so you can
  41. return any other markup understood by the script and have it handled
  42. appropriately.
  43. Interpolated variables - actually keys to %TEMPLATE, for the moment:
  44. <perl>$TEMPLATE{dog} = "Ralph"; return '';</perl>
  45. <p>My dog is named ${dog}.</p>
  46. Embedded code and variables are mostly intended for use in header and
  47. footer files, where it's handy to drop in titles or conditionalize
  48. aspects of a layout. You want to be careful with this sort of thing -
  49. it's useful in small doses, but it's also a maintainability nightmare
  50. waiting to happen. (WordPress, I am looking at you.)
  51. Several forms of lightweight markup:
  52. <wala>Wala::Markup, via Wala.pm - very basic wiki syntax</wala>
  53. <textile>Dean Allen's Textile, via Brad Choate's
  54. Text::Textile.</textile>
  55. <freeverse>An easy way to
  56. get properly broken lines
  57. -- en and em dashes ---
  58. for poetry and such.</freeverse>
  59. And a couple of shortcuts:
  60. <image>filename.ext
  61. alt text, if any</image>
  62. <list>
  63. one list item
  64. another list item
  65. </list>
  66. As it stands, freeverse, image, and list are not particularly robust.
  67. SUBROUTINES
  68. For no bigger than this thing is, it gets a little convoluted.
  69. handle()
  70. Handle queries.
  71. dir_list()
  72. Return a $sort_order sorted list of files matching $pattern in a
  73. directory. Called by year_print(), month_print(), and entry_print().
  74. calls $sort_order, which can be one of
  75. alpha - alphabetical
  76. reverse_alpha - alphabetical, reversed (might not work yet)
  77. high_to_low - numeric, high to low
  78. low_to_high - numeric, low to high
  79. year_print()
  80. List out the updates for a year. Calls dir_list(), entry_print().
  81. month_print()
  82. Prints the entries in a given month (nnnn/nn). Calls dir_list(),
  83. datestamp().
  84. entry_print()
  85. Prints the contents of a given entry. Calls datestamp,
  86. fragment_print, dir_list, and icon_markup. Recursively calls itself.
  87. icon_markup()
  88. Check if an icon exists for a given entry if so, return markup to
  89. include it. Icons are PNG or JPEG image files following a specific
  90. naming convention:
  91. index.icon.[png|jp(e)g] for directories
  92. [filename].icon.[png|jp(e)g] for flat text files
  93. Called by entry_print, calls image_size, uses filename to determine
  94. type.
  95. datestamp()
  96. Returns a nice html datestamp for a given entry, including a
  97. wikilink for discussion and suchlike. Called by entry_print.
  98. fragment_print()
  99. Print a text fragment - a header, footer, update, etc. Called by
  100. main routines, used to print headers and footers. Calls
  101. fragment_slurp to get the fragment it's supposed to print. Returns 1
  102. on successful completion, 0 otherwise.
  103. fragment_slurp()
  104. Read a text fragment, call line_parse to take care of funky markup
  105. and interpreting embedded code, and then return it as a string.
  106. Takes one parameter, the name of the file, and returns '' if it's
  107. not an extant text file. Called by entry_print, at least
  108. line_parse()
  109. Performs substitutions on lines called by fragment_slurp, at least.
  110. Calls image_markup, Text::Textile, Wala::wiki_page_to_html,
  111. eval_perl. Returns string.
  112. Parses some special markup, specifically:
  113. <perl>embedded perl</perl>
  114. ${variable} interpolation from %DISPLAY_CONF
  115. <textile></textile> - Text::Textile to HTML
  116. <wala></wala> - Wala::wikify();
  117. <image>filename.ext</image>
  118. <freeverse></freeverse>
  119. <retcon></retcon>
  120. <list></list>
  121. eval_perl()
  122. Evaluate embedded Perl, replacing blocks enclosed with <perl> tags
  123. with whatever they return (well, evaluated in a scalar context).
  124. image markup()
  125. Parse out an image tag and return the appropriate html. Calls
  126. image_size. Called by line_parse.
  127. month_name()
  128. Turn numeric dates into English.
  129. feed_print()
  130. Dump out an Atom feed of entries for a month.
  131. Called from handle(), calls entry_print, requires
  132. XML::Atom::SimpleFeed.
  133. entry_markup()
  134. Return text wrapped in the appropriate markup for an entry. Just a
  135. wrapper around div() at the moment.
  136. div()
  137. Return text wrapped in a div of the specified class.
  138. a() Returns an HTML link. Called all over the place.
  139. ornament()
  140. Returns a type ornament.
  141. image_size()
  142. Returns (width, height) of a variety of image files. Called by
  143. icon_markup and line_parse. Uses Image::Size if available, otherwise
  144. uses a couple of built-in routines munged together from pngsize and
  145. jpegsize in wwwis, by Alex Knowles and Andrew Tong.
  146. SEE ALSO
  147. walawiki.org, Blosxom, rassmalog, Text::Textile, XML::Atom::SimpleFeed,
  148. Image::Size, CGI::Fast.
  149. AUTHOR
  150. Copyright 2001-2007 Brennen Bearnes
  151. Image sizing code (in image_size) derived from wwwis, by Alex Knowles
  152. and Andrew Tong.
  153. display.pl is free software; you can redistribute it and/or modify
  154. it under the terms of the GNU General Public License as published by
  155. the Free Software Foundation; either version 2 of the License, or
  156. (at your option) any later version.
  157. This program is distributed in the hope that it will be useful,
  158. but WITHOUT ANY WARRANTY; without even the implied warranty of
  159. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  160. GNU General Public License for more details.