nanoblogger-3.4.2/000755 000765 000024 00000000000 11336333423 014464 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/ChangeLog000644 000765 000024 00000004423 11336326253 016244 0ustar00kevinwstaff000000 000000 2010-02-15 19:07 n1xt3r * ChangeLog, default/templates/main_index.htm, nb, plugins/atom.sh, plugins/rss2.sh, plugins/weblog_links.sh: - Fix: wrong logic found in load_plugins() loop, could cause loop to exit before completion. - Improves integration of feed links. 2010-02-15 03:18 n1xt3r * default/blog.conf, docs/nanoblogger.html, plugins/atom.sh, plugins/page/feed_links.sh, plugins/rss2.sh: Cleans up logic for toggling category based syndication. 2010-02-15 01:14 n1xt3r * default/templates/archive_index.htm, default/templates/year_archive.htm, docs/nanoblogger.html, nb.conf, plugins/archive/master_index.sh, plugins/entry/format/autobr.sh, plugins/entry/format/autotag-br.sh, plugins/page/feed_links.sh, plugins/weblog_status.sh: Fix: missing syndication links in archives (Charles Curley). 2010-02-14 20:42 n1xt3r * lib/tools.sh, plugins/atom.sh, plugins/entry/format/autobr.sh, plugins/entry/format/markdown.sh, plugins/entry/format/raw.sh, plugins/rss2.sh: - Corrects several plugins which wrongly utilized NB_EntryBody over NB_MetaBody. - Repackages with the original and much cleaner shortcode plugin implementation. 2010-02-13 03:51 n1xt3r * lib/tools.sh, plugins/entry/mod/base_url.sh, plugins/entry/mod/moods.sh: Activates shortcode plugins for both entries and pages. 2010-02-13 02:54 n1xt3r * lib/tools.sh: Fix: Addresses issue where entry plugin data was not being properly retained by NB_EntryBody. 2009-08-10 00:27 n1xt3r * lang/en/help.txt, nb: Replaces $CURRENT_YEAR in help message text with $COPYRIGHT variable. 2009-08-10 00:01 n1xt3r * docs/nanoblogger.html, lang/en/help.txt, lib/tools.sh, nb, plugins/archive/year/year_archive.sh, plugins/calendar.sh, plugins/entry/format/markdown.sh, plugins/makepage/tidy.sh, plugins/page/format/markdown.sh, welcome-to-nb.txt: - Fixes more Bash 4 incompatibilites discovered by Tobias Rehbein. - Adds new nb_eval function as wrapper to internal eval command. - Adds dynamic variable, $CURRENT_YEAR for copyright. 2009-07-26 04:39 n1xt3r * nb: Changes version information to read "SVN", indicating unstable. 2009-07-25 18:00 n1xt3r * plugins/archive/master_index.sh: Fix: Bash 4 throwed error due to improper syntax formatting. nanoblogger-3.4.2/COPYING000644 000765 000024 00000043103 10750164037 015522 0ustar00kevinwstaff000000 000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. nanoblogger-3.4.2/copyright000644 000765 000024 00000002001 10750164037 016412 0ustar00kevinwstaff000000 000000 Copyright: Copyright © 2003, 2004, 2005, 2006, 2007, 2008 Kevin Wood License: Program sources and other auxiliary files ----------------------------------------- You are free to distribute this software under the terms of the GNU General Public License version 2. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. nanoblogger-3.4.2/default/000755 000765 000024 00000000000 11336333423 016110 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/docs/000755 000765 000024 00000000000 11336333423 015414 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/lang/000755 000765 000024 00000000000 11336333422 015404 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/lib/000755 000765 000024 00000000000 11336333423 015232 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/moods/000755 000765 000024 00000000000 11336333422 015604 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/nb000755 000765 000024 00000113273 11336333101 015011 0ustar00kevinwstaff000000 000000 #! /bin/bash ############################################################ # NanoBlogger 3.4.2 Copyright 2010 n1xt3r (Kevin R. Wood) # ############################################################ # Last modified: 2010-02-15T15:39:48-05:00 # nanoblogger's version. VERSION="3.4.2" # nanoblogger's copyright COPYRIGHT="2004-2010" # -- hardcoded paths -- # where to expect nanoblogger's base NB_BASE_DIR=`dirname $0` # where to expect nanoblogger's documentation NB_DOC_DIR="$NB_BASE_DIR/docs" # where to expect nanoblogger's conf file NB_CFG_DIR="$NB_BASE_DIR" # nanoblogger's language definitions directory. NB_LANG_DIR="${NB_BASE_DIR}/lang" # nanoblogger's module directory. NB_LIB_DIR="${NB_BASE_DIR}/lib" # -- # -- modules -- . ${NB_LIB_DIR}/error.sh . ${NB_LIB_DIR}/tools.sh . ${NB_LIB_DIR}/config.sh . ${NB_LIB_DIR}/database.sh . ${NB_LIB_DIR}/archive.sh # -- # load specified or default language load_lang(){ LOADLANG_CODE="$1" [ -z "$1" ] && LOADLANG_CODE="$NB_LANG" # always fallback to english if [ ! -d "${NB_LANG_DIR}/${LOADLANG_CODE}" ]; then LOADLANG_CODE=en; NB_LANG=en fi for lang_file in ${NB_LANG_DIR}/${LOADLANG_CODE}/*.lang; do . "$lang_file" done # configure language for docs if [ -f "$NB_DOC_DIR/nanoblogger_$LOADLANG_CODE.html" ]; then NB_DOC_FILE="$NB_DOC_DIR/nanoblogger_$LOADLANG_CODE.html" elif [ "$LOADLANG_CODE" = en ]; then # allow for non-existant nanoblogger_en.html NB_DOC_FILE="$NB_DOC_DIR/nanoblogger.html" fi } # ensure a sane configuration - do or die! check_config(){ deconfig; load_config load_lang [ ! -d "$NB_BASE_DIR" ] && die "`basename $0`: '$NB_BASE_DIR' - $checkconf_nobase." [ -z "$BLOG_DIR" ] && die "$checkconf_noblog" [ ! -z "$USR_BLOGCONF" ] && [ ! -f "$USR_BLOGCONF" ] && die "'$USR_BLOGCONF' - $checkconf_nousrconf" [ ! -d "$BLOG_DIR" ] && die "'$BLOG_DIR' - $checkconf_noblogdir" [ ! -d "$NB_DATA_DIR" ] && die "'$NB_DATA_DIR' - $checkconf_nodata" [ ! -d "$BLOG_DIR/$CACHE_DIR" ] && die "'$CACHE_DIR' - $checkconf_nocache" [ ! -d "$BLOG_DIR/$PARTS_DIR" ] && die "'$PARTS_DIR' - $checkconf_nocache" [ ! -d "$NB_TEMPLATE_DIR" ] && die "'$NB_TEMPLATE_DIR' - $checkconf_notemplates" [ ! -w "$NB_TEMP_DIR" ] && die "'$NB_TEMP_DIR' - $nowritedir" [ ! -w "$BLOG_DIR" ] && die "'$BLOG_DIR' - $nowritedir" # if we're still alive set trap for special temp files SCRATCH_FILE="$NB_TEMP_DIR/nb_scratch$$" NB_TEMP_FILES="$NB_TEMP_DIR/nb_entry$$.* $SCRATCH_FILE*" trap "rm -fr $NB_TEMP_FILES; exit" 0 1 2 3 15 # activate custom file creation mask [ ! -z "$NB_UMASK" ] && umask $NB_UMASK } # edit $BLOG_CONF config_weblog(){ PREV_CHRONORDER="$CHRON_ORDER" nb_edit "$BLOG_CONF" # check if file's been modified since opened [ ! -N "$BLOG_CONF" ] && die "$configweblog_nomod" deconfig; load_config # set flag to resort databases if chronological order has changed # NOTE: rendered ineffective outside configure action [ "$PREV_CHRONORDER" != "$CHRON_ORDER" ] && RESORT_DATABASE=1 } # load specified plugins (defaults to all) from $PLUGINS_DIR load_plugins(){ PLUGIN_DIR="$1" PLUGINS_LIST=( ${@:1} ) add_plugin_script(){ plugin_file="$1" if [ -f "$plugin_file" ]; then plugin_basefile="${PLUGIN_DIR}/${plugin_file##*\/}" plugin_basefile="${plugin_basefile##\/}" plugin_rmdir="${PLUGIN_DIR}/" plugin_rmfile="${plugin_rmdir##\/}${plugin_basefile##*\/}" # remove plugins while we add them to eliminate duplications plugin_scripts=(${plugin_scripts[@]//$plugin_rmfile/} "$plugin_basefile" ) fi } # determine the plugin direcory [ ! -z "$PLUGIN_DIR" ] && PLUGIN_DIR="/$1" # cleanup any trailing slashes in $USR_PLUGINSDIR USR_PLUGINSDIR=${USR_PLUGINSDIR%%\/} # allow loading plugins individually if [ -f "${USR_PLUGINSDIR}${PLUGIN_DIR}" ] || [ -f "${PLUGINS_DIR}${PLUGIN_DIR}" ]; then PLUGIN_BASEFILE="${PLUGIN_DIR##*\/}" PLUGIN_BASEDIR="${PLUGIN_DIR//\/${PLUGIN_BASEFILE}/}" PLUGIN_DIR="$PLUGIN_BASEDIR" fi # determine the plugins directory list if [ -d "${USR_PLUGINSDIR}${PLUGIN_DIR}" ] && [ -d "${PLUGINS_DIR}${PLUGIN_DIR}" ]; then if [ "${PLUGINS_DIR}" != "${USR_PLUGINSDIR}" ]; then PLUGINSDIR_LIST="${USR_PLUGINSDIR}${PLUGIN_DIR} ${PLUGINS_DIR}${PLUGIN_DIR}" else PLUGINSDIR_LIST="${PLUGINS_DIR}${PLUGIN_DIR}" fi elif [ -d "${USR_PLUGINSDIR}${PLUGIN_DIR}" ]; then PLUGINSDIR_LIST="${USR_PLUGINSDIR}${PLUGIN_DIR}" elif [ -d "${PLUGINS_DIR}${PLUGIN_DIR}" ]; then PLUGINSDIR_LIST="${PLUGINS_DIR}${PLUGIN_DIR}" fi # initialise the array of plugins plugin_scripts=() for plugin_path in $PLUGINSDIR_LIST; do # break out of loop on bogus plugin path with last error value [ ! -d "$plugin_path" ] && return # add single plugin specified to load then drop out of loop if [ ! -z "$PLUGIN_BASEFILE" ]; then add_plugin_script "$plugin_path/$PLUGIN_BASEFILE" break fi # was more than one plugin name defined? PLUGINLIST_DEFINED=`echo "${PLUGINS_LIST[*]}" |grep -c '.[ ].'` if [ "$PLUGINLIST_DEFINED" != 0 ] ; then # yes, so we add them in order specified (removing any commas) for plugin in ${PLUGINS_LIST[@]//\,/}; do nb_plugin="$plugin_path/${plugin//[ ][ ]/}.sh" add_plugin_script "$nb_plugin" done else # no plugins specified, so get them all for nb_plugin in "$plugin_path"/*.sh ; do add_plugin_script "$nb_plugin" done fi done PLUGIN_BASEFILE= # load user and main plugins in alpha-numeric order (0-9, A-z) for nb_plugin in ${plugin_scripts[@]}; do #nb_msg "loading ../$nb_plugin ..." # allow user plugins to override and disable main plugins nbpl_prefix=${nb_plugin%%.sh} nbpl_glob=`echo "${PLUGINS_DIR}/${nbpl_prefix}".*` nbupl_glob=`echo "${USR_PLUGINSDIR}/${nbpl_prefix}".*` if [ -f "${PLUGINS_DIR}/$nb_plugin" ] && [ -f "${USR_PLUGINSDIR}/$nb_plugin" ]; then # plugin.sh exists in both places, user plugin.sh takes precedence #nb_msg "loading ... ${USR_PLUGINSDIR}/$nb_plugin" . "${USR_PLUGINSDIR}/$nb_plugin" elif [ -f "$nbupl_glob" ] && [ ! -f "${USR_PLUGINSDIR}/${nb_plugin}" ]; then # something other than plugin.sh exists continue # stay in loop, but skip to next in list elif [ -f "${USR_PLUGINSDIR}/$nb_plugin" ]; then # plugin.sh only exists in one place #nb_msg "loading ... ${USR_PLUGINSDIR}/$nb_plugin" . "${USR_PLUGINSDIR}/$nb_plugin" elif [ -f "$nbpl_glob" ] && [ ! -f "${PLUGINS_DIR}/${nb_plugin}" ]; then # something other than plugin.sh exists continue # stay in loop, but skip to next in list elif [ -f "${PLUGINS_DIR}/$nb_plugin" ]; then # plugin.sh only exists in on place #nb_msg "loading ... ${PLUGINS_DIR}/$nb_plugin" . "${PLUGINS_DIR}/$nb_plugin" fi done } # filter content through a template load_template(){ TEMPLATE_FILE="$1" if [ -f "$TEMPLATE_FILE" ]; then # prefix lines with an X TEMPLATE=`sed -e '/^/ s//X: /' < "$TEMPLATE_FILE"` # remove X's and source variables into a temp file cat > "$SCRATCH_FILE".template <<-EOF sed -e '/^X:[ ]/ s///' <> "$SCRATCH_FILE".newentry_list [ ! -z "$next_entry" ] && echo "$next_entry" >> "$SCRATCH_FILE".newentry_list UPDATE_LIST=(`sort -u "$SCRATCH_FILE".newentry_list`) fi } init_plugins(){ # setup cache for plugins export CACHE_TYPE=plugin # always load main plugins load_plugins } init_main(){ # build main weblog index nb_msg "$buildweblog_main" export CACHE_TYPE=main # reset UPDATE_LIST so main index gets updated query_db "$MAINPAGE_QUERY" nocat UPDATE_LIST=(${DB_RESULTS[*]}) paginate "$MAINPAGE_QUERY" nocat "$MAX_MAINPAGE_ENTRIES" "$MAIN_TEMPLATE" \ "$ENTRY_TEMPLATE" "$BLOG_DIR/" "$NB_INDEXFILE" if [ "$NB_QUERY" != main ]; then # remove any expired cache data to save disk space if [ "$BLOG_CACHEMNG" != 0 ]; then nb_msg "$buildweblog_cache" update_cache expired fi fi # load post plugins load_plugins post if [ "$SHOW_TIMES" = 1 ] && [ "$VERBOSE" != 0 ]; then times fi } nb_msg "$buildweblog_files" case "$NB_QUERY" in tag|tag[a-z]|cat) [ -z "$cat_num" ] && NB_UPDATE=catarch; NB_QUERY=all; init_update; init_plugins; build_catarchives; init_main ;; main) db_query=main; init_update; init_plugins; init_main ;; *) # build/update archives based on the query results if [ "$NB_QUERY" != main ]; then init_update; init_plugins; build_archives; init_main; fi ;; esac } # add new entry add_entry(){ # acquire and validate specified categories if [ ! -z "$cat_num" ]; then db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" nb_msg "$addentry_catinfo $cat_num ..." fi nb_msg "$addentry_action" # generate formatted date string for entry's metadata meta_timestamp; NB_EntryDate="$NB_MetaDate" # load user specified timestamp if [ -f "$NB_EditFile" ]; then read_metadata TIMESTAMP "$NB_EditFile" New_TimeStamp="$METADATA" fi New_EntryFile="$NB_MetaTimeStamp.$NB_DATATYPE" # dump all custom modications from edit file to new entry's data file if [ -f "$NB_EditFile" ]; then cat "$NB_EditFile" > "$NB_DATA_DIR/$New_EntryFile" elif [ -f "$IMPORT_FILE" ]; then # dump all custom modifications from import file to new entry's data file cat "$IMPORT_FILE" > "$NB_DATA_DIR/$New_EntryFile" fi # save date metadata to entry's data file [ -f "$NB_DATA_DIR/$New_EntryFile" ] && write_var DATE "$NB_EntryDate" "$NB_DATA_DIR/$New_EntryFile" # use specified timestamp as entry's new date chg_entrydate "$New_EntryFile" "$New_TimeStamp" [ ! -z "$New_EntryDateFile" ] && New_EntryFile="$New_EntryDateFile" # add to specified categories if [ ! -z "$cat_num" ]; then for cat_db in $db_catquery; do update_catdb "$New_EntryFile" "$NB_DATA_DIR/$cat_db" done fi echo "$New_EntryFile" >> "$SCRATCH_FILE".newentry_list UPDATE_LIST=(`sort -u "$SCRATCH_FILE".newentry_list`) find_categories "${UPDATE_LIST[*]}" nb_msg "$querydb_update" update_maindb "$New_EntryFile" "$NB_DATA_DIR/master.db" update_categories resort_categories resort_db "$NB_DATA_DIR/master.db" } # edit entry or tag by id number edit_weblog(){ case "$editweblog_type" in entry) # edit entries NUMVAR=`echo "$edit_idsel" |grep '[0-9]' |sed -e '/[\,]/ s// /g; /[A-Z,a-z\)\.\-]/d'` [ -z "$NUMVAR" ] && die "$novalid_entryid" db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" # find entry id(s) from specified query [ ! -z "$NB_QUERY" ] && db_query="$NB_QUERY" query_db "$db_query" "$db_catquery"; ENTRY_LIST=(${DB_RESULTS[*]}) for entry_id in $NUMVAR; do # adjust offset by 1 for arrays (1 = 0) ((entry_id--)) Edit_EntryFile=${ENTRY_LIST[$entry_id]} [ ! -f "$NB_DATA_DIR/$Edit_EntryFile" ] && die "$invalid_entryid $edit_idsel" done > "$SCRATCH_FILE".edit_weblog # for chg_entrydate [ ! -z "$cat_num" ] && nb_msg "$editweblog_catinfo $cat_num" for entry_id in $NUMVAR; do ((entry_id--)) # adjust offset by 1 for arrays (1 = 0) Edit_EntryFile=${ENTRY_LIST[$entry_id]} read_metadata TITLE "$NB_DATA_DIR/$Edit_EntryFile" OldEdit_EntryTitle="$METADATA" # write any user metadata write_var "$USR_METAVAR" "$USR_SETVAR" "$NB_DATA_DIR/$Edit_EntryFile" nb_edit -p "$NB_DATA_DIR/$Edit_EntryFile" # validate metafile check_metavars "TITLE: AUTHOR: DATE: BODY: $METADATA_CLOSEVAR" \ "$NB_DATA_DIR/$Edit_EntryFile" # load user specified timestamp read_metadata TIMESTAMP "$NB_DATA_DIR/$Edit_EntryFile" New_TimeStamp="$METADATA" # use specified timestamp as entry's new date chg_entrydate "$Edit_EntryFile" "$New_TimeStamp" [ -f "$NB_DATA_DIR/$New_EntryDateFile" ] && Edit_EntryFile="$New_EntryDateFile" # add timestamp modified entries to update list if [ ! -z "$Old_EntryFile" ]; then echo "$Old_EntryFile" >> "$SCRATCH_FILE".edit_weblog nb_msg "$querydb_update" find_categories "$Old_EntryFile" for olde_catdb in ${CAT_LIST[*]}; do delete_db "$Old_EntryFile" "$NB_DATA_DIR/$olde_catdb" done delete_db "$Old_EntryFile" "$NB_DATA_DIR/master.db" update_maindb "$Edit_EntryFile" "$NB_DATA_DIR/master.db" update_categories "$Edit_EntryFile" resort_categories resort_db "$NB_DATA_DIR/master.db" fi # use cached version for 'newer than' comparison nt_cachefile=`echo "$BLOG_DIR/$CACHE_DIR/$Edit_EntryFile".*` nt_cachefile=${nt_cachefile//[ ]*/} if [ "$NB_DATA_DIR/$Edit_EntryFile" -nt "$nt_cachefile" ]; then read_metadata TITLE "$NB_DATA_DIR/$Edit_EntryFile" NewEdit_EntryTitle="$METADATA" # update previous and next entries of modified entry query_db master findba_entries "$Edit_EntryFile" "${MASTER_DB_RESULTS[*]}" set_entrynavlinks prev "$before_entry" set_entrynavlinks next "$after_entry" [ ! -z "$prev_entry" ] && echo "$prev_entry" >> "$SCRATCH_FILE".edit_weblog [ ! -z "$next_entry" ] && echo "$next_entry" >> "$SCRATCH_FILE".edit_weblog echo "$Edit_EntryFile" >> "$SCRATCH_FILE".edit_weblog # remove old cache data for clean build rm -f "$BLOG_DIR/$CACHE_DIR/$Edit_EntryFile".* # remove old entry archive directory set_entrylink "$Edit_EntryFile" Delete_EntryArchiveDir="$BLOG_DIR/$ARCHIVES_DIR/$entry_dir/$entry_linkname" [ ! -z "$entry_linkname" ] && [ -d "$Delete_EntryArchiveDir" ] && rm -fr "$Delete_EntryArchiveDir" fi done NB_QUERY=; UPDATE_LIST=(`sort -u "$SCRATCH_FILE".edit_weblog`) if [ ! -z "${UPDATE_LIST[*]}" ]; then nb_msg "$editweblog_action" find_categories "${UPDATE_LIST[*]}" resort_categories build_weblog else die "$editweblog_noaction" fi ;; meta-file|file) # edit files nb_draft "$edit_idsel" ;; tag|cat) # edit categories cat_num="$edit_idsel"; cat_var=`echo "$cat_num" |sed -e '/,/d'` [ -z "$cat_var" ] && die "$editweblog_onecat" db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" nb_msg "$editweblog_catinfo $cat_num" if [ ! -z "$USR_TITLE" ]; then set_catlink "$db_catquery" [ ! -z "$category_dir" ] && [ -d "$BLOG_DIR/$ARCHIVES_DIR/$category_dir" ] && rm -fr "$BLOG_DIR/$ARCHIVES_DIR/$category_dir" new_usrtitle=`translit_text "$USR_TITLE"` nb_msg "$editweblog_title '$new_usrtitle' ..." echo "$new_usrtitle" > "$NB_DATA_DIR/$db_catquery".tmp && \ sed 1d "$NB_DATA_DIR/$db_catquery" >> "$NB_DATA_DIR/$db_catquery".tmp && \ mv "$NB_DATA_DIR/$db_catquery".tmp "$NB_DATA_DIR/$db_catquery" NB_QUERY=; UPDATE_LIST=(`sed 1d "$NB_DATA_DIR/$db_catquery" |sort -u`) find_categories "${UPDATE_LIST[*]}" resort_categories build_weblog; exit else die "$editweblog_nomod" fi ;; *) die "$main_badopts $editweblog_type";; esac } # delete entry or category by id number delete_weblog(){ # find entry id(s) from specified query [ ! -z "$NB_QUERY" ] && db_query="$NB_QUERY" db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" cat_list="$db_catquery" case "$delweblog_type" in entry) # delete entries NUMVAR=`echo "$delete_idsel" |grep '[0-9]' |sed -e '/[\,]/ s// /g; /[A-Z,a-z\)\.\-]/d'` [ -z "$NUMVAR" ] && die "$novalid_entryid" if [ ! -z "$cat_list" ]; then CATNUMVAR=`echo "$cat_num" |grep '[0-9]' |sed -e '/[\,]/ s// /g; /[A-Z,a-z\)\.\-]/d'` [ -z "$CATNUMVAR" ] && die "$deleteweblog_onecat" fi [ ! -z "$NB_QUERY" ] && db_query="$NB_QUERY" query_db "$db_query" "$cat_list"; ENTRY_LIST=(${DB_RESULTS[*]}) for entry_id in $NUMVAR; do # adjust offset by 1 for arrays (1 = 0) old_entryid="$entry_id" ((entry_id--)) Delete_EntryFile=${ENTRY_LIST[$entry_id]} [ ! -f "$NB_DATA_DIR/$Delete_EntryFile" ] && die "$invalid_entryid $delete_idsel" read_metadata TITLE "$NB_DATA_DIR/$Delete_EntryFile"; Delete_EntryTitle=`echo "${METADATA:0:25}"`.. delete_titles="$delete_titles $old_entryid=$Delete_EntryTitle," done delete_titles=`echo "$delete_titles" |sed -e '/^[ ]/ s///; /[\,]$/ s///'` [ ! -z "$cat_num" ] && nb_msg "$deleteweblog_catinfo $cat_num" nb_msg "$deleteweblog_delentry $delete_idsel ($delete_titles) ..." # confirm delete in interactive mode [ "$BLOG_INTERACTIVE" = 1 ] && confirm_action # initialize master.db if [ ! -z "$NB_QUERY" ]; then db_query="$NB_QUERY" else db_query=master fi query_db "$db_query" > "$SCRATCH_FILE"; > "$SCRATCH_FILE.x-update" nb_msg "$querydb_update" for entry_id in $NUMVAR; do # adjust offset by 1 for arrays (1 = 0) ((entry_id--)) Delete_EntryFile=${ENTRY_LIST[$entry_id]} if [ -f "$NB_DATA_DIR/$Delete_EntryFile" ]; then echo "$Delete_EntryFile" >> "$SCRATCH_FILE" if [ ! -z "${cat_list[*]}" ]; then # deletes entry from categories for cat_db in ${cat_list[@]}; do cat_match=`grep -c "$Delete_EntryFile" "$NB_DATA_DIR/$cat_db"` [ "$cat_match" -ge 1 ] && echo "$cat_db" >> "$SCRATCH_FILE.x-catdbs" delete_db "$Delete_EntryFile" "$NB_DATA_DIR/$cat_db" done update_maindb "$Delete_EntryFile" "$NB_DATA_DIR/master.db" else # permanently deletes entry for cat_db in ${db_categories[@]}; do cat_match=`grep -c "$Delete_EntryFile" "$NB_DATA_DIR/$cat_db"` [ "$cat_match" -ge 1 ] && echo "$cat_db" >> "$SCRATCH_FILE.x-catdbs" delete_db "$Delete_EntryFile" "$NB_DATA_DIR/$cat_db" done set_entrylink "$Delete_EntryFile" Delete_PermalinkFile="$BLOG_DIR/$ARCHIVES_DIR/$permalink_file" Delete_EntryArchiveDir="$BLOG_DIR/$ARCHIVES_DIR/$entry_dir/$entry_linkname" # delete permalink file [ -f "$Delete_PermalinkFile" ] && rm -fr "$Delete_PermalinkFile" # delete permalink directory [ ! -z "$entry_linkname" ] && [ -d "$Delete_EntryArchiveDir" ] && rm -fr "$Delete_EntryArchiveDir" # delete old cache data rm -f "$BLOG_DIR/$CACHE_DIR/$Delete_EntryFile".* # update previous and next entries of deleted entry query_db master findba_entries "$Delete_EntryFile" "${MASTER_DB_RESULTS[*]}" set_entrynavlinks prev "$before_entry" set_entrynavlinks next "$after_entry" delete_db "$Delete_EntryFile" "$NB_DATA_DIR/master.db" rm -f "$NB_DATA_DIR/$Delete_EntryFile" echo "$Delete_EntryFile" >> "$SCRATCH_FILE.x-entries" # hide prev and next entries from category updates [ ! -z "$prev_entry" ] && echo "$prev_entry" >> "$SCRATCH_FILE.x-update" [ ! -z "$next_entry" ] && echo "$next_entry" >> "$SCRATCH_FILE.x-update" fi fi done NB_QUERY=; UPDATE_LIST=(`sort -u "$SCRATCH_FILE"`) # update all categories with removed entries [ ! -z "${UPDATE_LIST[*]}" ] && find_categories "${UPDATE_LIST[*]}" [ -f "$SCRATCH_FILE.x-catdbs" ] && CAT_XLIST=(`sort -u "$SCRATCH_FILE.x-catdbs"`) [ ! -z "${CAT_XLIST[*]}" ] && CAT_LIST=(`for xcatdb in ${CAT_LIST[@]} ${CAT_XLIST[@]}; do echo $xcatdb; done |sort -u`) # prune all removed entries from update list if [ -f "$SCRATCH_FILE.x-entries" ]; then for xentry in $(< "$SCRATCH_FILE.x-entries"); do sed -e '/'$xentry'/d' "$SCRATCH_FILE".x-update > "$SCRATCH_FILE".x-update.new && \ mv "$SCRATCH_FILE".x-update.new "$SCRATCH_FILE".x-update done UPDATE_LIST=(`sort -u "$SCRATCH_FILE.x-update"`) fi update_categories resort_categories build_weblog ;; tag|cat) # delete categories cat_num="$delete_idsel" [ -z "$cat_num" ] && die "$checkcatid_novalid" db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" cat_list="$db_catquery" nb_msg "$deleteweblog_delcat $cat_num ..." # confirm delete in interactive mode [ "$BLOG_INTERACTIVE" = 1 ] && confirm_action query_db "$db_query" "${cat_list[*]}" echo "${DB_RESULTS[*]}" > $SCRATCH_FILE for cat_db in ${cat_list[@]}; do Delete_CatDBFile="$cat_db" [ -f "$NB_DATA_DIR/$cat_db" ] && set_catlink "$cat_db" [ ! -z "$category_dir" ] && [ -d "$BLOG_DIR/$ARCHIVES_DIR/$category_dir" ] && rm -fr "$BLOG_DIR/$ARCHIVES_DIR/$category_dir" rm -f "$NB_DATA_DIR/$cat_db" "$BLOG_DIR/$ARCHIVES_DIR"/`chg_suffix "$cat_db"` done; cat_num= NB_QUERY=; UPDATE_LIST=(`sort -u "$SCRATCH_FILE"`) [ ! -z "${UPDATE_LIST[*]}" ] && find_categories "${UPDATE_LIST[*]}" nb_msg "$querydb_update" for oldcat_dbitem in ${UPDATE_LIST[*]}; do update_maindb "$oldcat_dbitem" "$NB_DATA_DIR/master.db" done resort_db "$NB_DATA_DIR/master.db" build_weblog; exit ;; *) die "$main_badopts $delweblog_type";; esac } # assign categories to entries cat_entry(){ NUMVAR=`echo "$catentry_num" |grep '[0-9]' |sed -e '/[\,]/ s// /g; /[A-Z,a-z\)\.\-]/d'` [ -z "$NUMVAR" ] && die "$novalid_entryid" [ ! -z "$NB_QUERY" ] && db_query="$NB_QUERY" query_db "$db_query" for entry_id in $NUMVAR; do # adjust offset by 1 for arrays (1 = 0) old_entryid="$entry_id" ((entry_id--)) Cat_EntryFile=${DB_RESULTS[$entry_id]} [ ! -f "$NB_DATA_DIR/$Cat_EntryFile" ] && die "$invalid_entryid $catentry_num" read_metadata TITLE "$NB_DATA_DIR/$Cat_EntryFile"; Cat_EntryTitle=`echo "${METADATA:0:25}"`.. catentry_titles="$catentry_titles $old_entryid=$Cat_EntryTitle," done catentry_titles=`echo "$catentry_titles" |sed -e '/^[ ]/ s///; /[\,]$/ s///'` nb_msg "$catentry_catinfo $cat_num ..." nb_msg "$catentry_catging $catentry_num ($catentry_titles) ..." db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num"; [ -z "$cat_num" ] && die "$catentry_catfirst" # confirm category in interactive mode [ "$BLOG_INTERACTIVE" = 1 ] && confirm_action > "$SCRATCH_FILE" nb_msg "$querydb_update" query_db "$db_query" for entry_id in $NUMVAR; do # adjust offset by 1 for arrays (1 = 0) ((entry_id--)) Cat_EntryFile=${DB_RESULTS[$entry_id]} if [ -f "$NB_DATA_DIR/$Cat_EntryFile" ]; then echo "$Cat_EntryFile" >> "$SCRATCH_FILE" if [ ! -z "${cat_list[*]}" ]; then for cat_db in ${cat_list[@]}; do update_catdb "$Cat_EntryFile" "$NB_DATA_DIR/$cat_db" done fi update_maindb "$Cat_EntryFile" "$NB_DATA_DIR/master.db" fi done NB_QUERY=; UPDATE_LIST=(`sort -u "$SCRATCH_FILE"`) [ ! -z "${UPDATE_LIST[*]}" ] && find_categories "${UPDATE_LIST[*]}" update_categories resort_categories resort_db "$NB_DATA_DIR/master.db" build_weblog } # list entries and categories list_weblog(){ query_db; db_query="$NB_QUERY" # pre-processing for extensive list options if [ "$QUERY_WEBLOG" != 1 ]; then NB_QUERY="$listweblog_type"; db_query="$NB_QUERY" fi case "$listweblog_type" in tag|tag[a-z]|cat) if [ ! -z "$list_idsel" ]; then db_query=; cat_num="$list_idsel"; fi;; esac db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" explode_list(){ EXPLODE_RESULTS=($1) list_entryid=0 entry_items=${#EXPLODE_RESULTS[*]} id=0 while [ "$id" -lt "$entry_items" ]; do let list_entryid=${list_entryid}+1 entry=${EXPLODE_RESULTS[$id]%%>[0-9]*} entry_cat=${EXPLODE_RESULTS[$id]##*\>} read_metadata TITLE "$NB_DATA_DIR/$entry"; NB_EntryTitle="$METADATA" [ "$entry_cat" != "$entry" ] && entry_catids="- [$entry_cat]" entry_date=${entry%%.$NB_DATATYPE}; entry_date=${entry_date//\_/:} NB_EntryDate=${entry_date//[A-Z]/ } echo " $list_entryid, $NB_EntryTitle - ($NB_EntryDate) $entry_catids" let id=${id}+1 entry_cat=; entry_catids=; entry= done } # lists categories case "$db_query" in tag|tag[a-z]|cat) [ -z "${db_categories[*]}" ] && die "$listweblog_nocat" nb_msg "$header_ID, $header_Title" query_db; id=0 cat_items=${#db_categories[*]} while [ "$id" -le "$cat_items" ]; do let id=${id}+1 [ -f "$NB_DATA_DIR/cat_$id.$NB_DBTYPE" ] && echo " $id, `nb_print "$NB_DATA_DIR"/cat_$id.$NB_DBTYPE 1`" done; exit;; esac list_entries(){ [ -z "$db_query" ] && db_query="$QUERY_MODE" list_query="$db_query" # raw_db necessary for including category info raw_db "$db_query" "$db_catquery" [ -z "${DB_RESULTS[*]}" ] && die "'$list_query' - $listweblog_nomatch" } # lists entries case "$db_query" in a|any|all|entry|entries) db_query=all; list_entries nb_msg "$header_ID, $header_Title - ($header_Date) - [$header_Category]" explode_list "${DB_RESULTS[*]}";; ""|main|max|[0-9]*) list_entries nb_msg "$header_ID, $header_Title - ($header_Date) - [$header_Category]" explode_list "${DB_RESULTS[*]}";; *) die "$main_badopts $listweblog_type";; esac } # create a new entry, category or weblog directory add_weblog(){ process_entry(){ if [ -z "$USR_ADDFILE" ]; then # read user specified attributes for entry (interactively) if [ -z "$USR_AUTHOR" ] && [ "$BLOG_INTERACTIVE" = 1 ]; then echo "$addweblog_author [$BLOG_AUTHOR]" read -p "$NB_PROMPT" NB_EntryAuthor fi if [ -z "$USR_TITLE" ] && [ "$BLOG_INTERACTIVE" = 1 ]; then echo "$addweblog_title" read -p "$NB_PROMPT" NB_EntryTitle fi [ ! -z "$USR_TEXT" ] && NB_EntryBody="$USR_TEXT"; USR_TEXT= [ ! -z "$USR_DESC" ] && NB_EntryDescription="$USR_DESC" # prompt for description interactively if [ -z "$NB_EntryDescription" ] && [ "$DESC_PROMPT" != 1 ] && [ "$BLOG_INTERACTIVE" = 1 ]; then echo "$addweblog_desc" read -p "$NB_PROMPT" NB_EntryDescription fi fi [ ! -z "$USR_TITLE" ] && NB_EntryTitle="$USR_TITLE"; USR_TITLE= [ ! -z "$USR_AUTHOR" ] && NB_EntryAuthor="$USR_AUTHOR" [ -z "$NB_EntryAuthor" ] && NB_EntryAuthor="$BLOG_AUTHOR" [ -z "$NB_EntryFormat" ] && NB_EntryFormat="$ENTRY_FORMAT" # set a default entry format [ -z "$NB_EntryFormat" ] && NB_EntryFormat="$ENTRY_FORMAT" # create new temp file for prepping the entry's data file NB_EditFile="$BLOG_DIR/nb_edit-entry-`nb_timestamp`.$NB_DATATYPE" # save current metadata to temp file write_entry "$NB_EditFile" # save user metadata and preserve structure from imported file if [ -f "$IMPORT_FILE" ]; then write_var "$USR_METAVAR" "$USR_SETVAR" "$IMPORT_FILE" cat "$IMPORT_FILE" > "$NB_EditFile" fi if [ -z "$NB_EntryBody" ]; then nb_msg "$addweblog_editnew" nb_edit -p "$NB_EditFile" # preserve custom meta variable and data [ ! -z "$USR_METAVAR" ] && read_metadata "$USR_METAVAR" "$NB_EditFile"; USR_SETVAR="$METADATA" write_var "$USR_METAVAR" "$USR_SETVAR" "$NB_EditFile" # validate metafile check_metavars "TITLE: AUTHOR: DATE: BODY: $METADATA_CLOSEVAR" \ "$NB_EditFile" fi } # process new process_new(){ add_entry build_weblog # remove editing session file upon success [ $? = 0 ] && [ -f "$NB_EditFile" ] && rm -fr "$NB_EditFile" # prompt for some post-tasks [ ! -z "$BLOG_PREVIEW_CMD" ] && preview_weblog [ ! -z "$BLOG_PUBLISH_CMD" ] && publish_weblog } load_config case "$addweblog_type" in article) check_config # verify articles directories for articlesection in ${ARTICLES_DIR[@]}; do [ ! -d "$BLOG_DIR/$articlesection" ] && die "$addweblog_noarticledir" done USR_ARTICLEFILE="$USR_ADDFILE"; NB_ArticleFile= if [ -z "$USR_ARTICLEFILE" ]; then NB_ArticleFile="$BLOG_DIR/nb_edit-article-`nb_timestamp`.$ARTICLES_SUFFIX" USR_ARTICLEFILE="$NB_ArticleFile" fi [ ! -z "$USR_TITLE" ] && NB_MetaTitle="$USR_TITLE" # determine the articles destination article_dirname=`dirname "$USR_ARTICLEFILE"`; article_dir=${ARTICLES_DIR%%[ ]*} article_dirbase=${article_dirname//$BLOG_DIR}; article_dirbase=${article_dirbase//$article_dir} article_dirbase=/${article_dirbase##*\/}; article_dirbase=${article_dirbase%%\/} [ "${article_dirname//$BLOG_DIR}" = "$article_dirname" ] && article_dirbase= article_filename=`chg_suffix "$article_filename" "$ARTICLES_SUFFIX"` if [ -d "$article_dirname" ] && [ ! -f "$USR_ARTICLEFILE" ]; then [ ! -z "$NB_ArticleFile" ] && make_file "$NB_ArticleFile" "$USR_TEMPLATE" article_created=1; nb_draft -p "$USR_ARTICLEFILE" fi [ ! -f "$USR_ARTICLEFILE" ] && die "$addweblog_noarticlesrc" check_metavars "TITLE: BODY: $METADATA_CLOSEVAR" "$USR_ARTICLEFILE" if [ ! -z "$NB_ArticleFile" ]; then read_metadata TITLE "$USR_ARTICLEFILE" if [ ! -z "$METADATA" ]; then article_filename=`translit_text "$METADATA"`.$ARTICLES_SUFFIX else article_filename=`translit_text "$notitle"`.$ARTICLES_SUFFIX fi else article_filename=`basename "$USR_ARTICLEFILE"` fi if [ "$article_created" != 1 ]; then [ -f "$BLOG_DIR/$article_dir${article_dirbase}/$article_filename" ] && die "'$BLOG_DIR/$article_dir${article_dirbase}/$article_filename' - $samefilename" fi if [ ! -z "$article_dir" ] && [ -d "$BLOG_DIR/$article_dir${article_dirbase}" ]; then article_internal=${article_dirname//*${article_dir}*/true} if [ ! -z "$article_dirbase" ] || [ "$article_internal" != "true" ]; then if [ ! -f "$BLOG_DIR/$article_dir${article_dirbase}/$article_filename" ]; then cp "$USR_ARTICLEFILE" \ "$BLOG_DIR/$article_dir${article_dirbase}/$article_filename" || exit article_copied=1 fi fi [ -f "$NB_ArticleFile" ] && rm -f "$NB_ArticleFile" if [ "$article_created" = 1 ] || [ "$article_copied" = 1 ]; then nb_msg "$addweblog_newarticle" NB_QUERY=main; build_weblog # prompt for some post-tasks [ ! -z "$BLOG_PREVIEW_CMD" ] && preview_weblog [ ! -z "$BLOG_PUBLISH_CMD" ] && publish_weblog exit fi fi die "$addweblog_noarticlesrc" ;; entry) check_config # add new entry from metafile [ ! -z "$USR_ADDFILE" ] && import_file "$USR_ADDFILE" process_entry; process_new ;; weblog) [ -z "$BLOG_DIR" ] && die "$addweblog_noweblog" [ -d "$BLOG_DIR" ] && die "$addweblog_nocreate" # create new weblog directory ... if [ ! -d "$BLOG_DIR" ]; then nb_msg "$addweblog_newblog '$BLOG_DIR' ..." mkdir -p "$BLOG_DIR" [ ! -d "$BLOG_DIR" ] && die "$addweblog_nocreate" > "$BLOG_DIR/.nb_newblogdir" nb_msg "$addweblog_copyaction" # copy default files and directories for weblog_dir in "$NB_BASE_DIR"/default/*; do cp -R "$weblog_dir" "$BLOG_DIR" done # create some critical empty directories for weblog_emptydir in "$ARCHIVES_DIR" "$CACHE_DIR" "$PARTS_DIR"; do [ ! -d "$BLOG_DIR/$weblog_emptydir" ] && mkdir "$BLOG_DIR/$weblog_emptydir" done # ... prompt for configuration, unless interactive mode is 0 if [ "$BLOG_INTERACTIVE" = 0 ]; then choice=n else echo "$addweblog_askconf [Y/n]" read -p "$NB_PROMPT" choice fi case $choice in [Yy]|"") nb_msg "$addweblog_confaction" nb_edit "$BLOG_DIR"/blog.conf check_config; build_weblog exit;; [Nn]) check_config; build_weblog nb_msg "$addweblog_noconf" exit;; esac fi ;; tag|cat) check_config # create a new category query_db id=0; cat_items=${#db_categories[*]} while [ "$id" -lt "$cat_items" ] || [ "$cat_items" = 0 ]; do let id=${id}+1 if [ ! -f "$NB_DATA_DIR/cat_$id.$NB_DBTYPE" ]; then nb_msg "$addweblog_newcat id: $id ..." if [ ! -z "$USR_TITLE" ]; then cat_title=$USR_TITLE; USR_TITLE= else echo "$addweblog_titlecat [$addweblog_untitled]" read -p "$NB_PROMPT" cat_title [ -z "$cat_title" ] && cat_title="$notitle" fi translit_text "$cat_title" > "$NB_DATA_DIR"/cat_$id.$NB_DBTYPE cat_num="$id"; db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" cat_items="$id" else let cat_items=${cat_items}+1 db_categories=(${db_categories[*]} cat_$id.$NB_DBTYPE) fi done newcat_title=`nb_print "$NB_DATA_DIR"/cat_$id.$NB_DBTYPE` nb_msg "$addweblog_madecat '$newcat_title'."; exit ;; *) die "$main_badopts $addweblog_type" ;; esac } show_help(){ nb_eval "date '+%Y' |grep '[0-9]'" && CURRENT_YEAR=`date '+%Y'` && COPYRIGHT="2004-$CURRENT_YEAR" NB_ShowHelp=$(< "${NB_LANG_DIR}/$NB_LANG"/help.txt) BASENAME=`basename $0` # transform keywords to variables and delete all hash-marked lines for display sed -e "/[\$]VERSION/ s//${VERSION}/g; /[\$]BASENAME/ s//${BASENAME}/g; /[\$]COPYRIGHT/ s//${COPYRIGHT}/g; /^[\#]/d" <<-EOF $NB_ShowHelp EOF } # load minimal configuration data required to operate load_globals load_lang [ $# -lt 1 ] && show_help check_arg(){ if [ -z "$1" ]; then echo "$bad_argument $checkarg_badarg" echo "$checkarg_help" exit 1 fi } sanity_check(){ invalid_opt=`echo "$@" |grep '^[--]$*'` [ ! -z "$invalid_opt" ] && argument= } while [ $# -gt 0 ]; do bad_argument=$1 # -a,-c,-d,-E,-e,-l,-m,-q,-u exists for backwards compability case "$1" in add|-a) check_arg "$2"; addweblog_type="$2"; shift; ADD_WEBLOG=1;; configure) CONFIG_WEBLOG=1;; edit) check_arg "$2"; editweblog_type="$2"; edit_idsel="$3"; shift 2 EDIT_WEBLOG=1;; -e) check_arg "$2"; editweblog_type=entry; edit_idsel="$2"; shift EDIT_WEBLOG=1;; # short option for backward compatibility delete) check_arg "$2"; delweblog_type="$2" case "$3" in [0-9]*) delete_idsel="$3"; shift 2;; *) shift;; esac; DELETE_WEBLOG=1;; -d) check_arg "$2"; delweblog_type=entry; delete_idsel="$2"; shift DELETE_WEBLOG=1;; # short option for backward compatibility draft|-E) check_arg "$2"; USR_DRAFTFILE="$2"; shift; DRAFT_WEBLOG=1;; import) check_arg "$2"; addweblog_type="$2"; USR_ADDFILE="$3"; shift 2 ADD_WEBLOG=1;; list|-l) listweblog_type="$2" case "$3" in [0-9]*) list_idsel="$3"; shift 2;; *) shift;; esac; LIST_WEBLOG=1;; make-page) check_arg "$2"; USR_MKPSRCFILE="$2"; USR_MKPOUTFILE="$3"; shift 2 MAKEPAGE_WEBLOG=1;; make-file) check_arg "$2"; USR_MKFFILE="$2"; shift; MAKEFILE_WEBLOG=1;; manual) load_config; load_lang; nb_browser "$NB_DOC_FILE"; exit;; tag-entry|-m) check_arg "$2"; catentry_num="$2"; shift; MOVE_WEBLOG=1;; publish) PUBLISH_WEBLOG=1;; preview) PREVIEW_WEBLOG=1;; update|-u) updweblog_type="$2"; case "$3" in [0-9]*) update_idsel="$3"; shift 2;; *) shift;; esac; UPDATE_WEBLOG=1;; update-cache) updcache_type="$2" case "$3" in [0-9]*) updatec_idsel="$3"; shift 2;; *) shift;; esac; UPDATECACHE_WEBLOG=1;; --author) check_arg "$2"; USR_AUTHOR="$2"; shift;; --conf-file) check_arg "$2"; USR_BLOGCONF="$2"; shift;; --data-dir) check_arg "$2"; USR_DATADIR="$2"; shift;; --desc) DESC_PROMPT=1; USR_DESC="$2"; shift;; --meta-file) check_arg "$2"; USR_ADDFILE="$2"; shift;; --title) check_arg "$2"; USR_TITLE="$2"; shift;; --plugin-dir) check_arg "$2"; USR_PLUGINSDIR="$2"; shift;; --query|-q) check_arg "$2"; NB_QUERY="$2"; shift; QUERY_WEBLOG=1;; --set-var) check_arg "$2"; USR_SETVAR="$2"; shift;; --tag|-c) check_arg "$2"; cat_num="$2"; shift;; --text) check_arg "$2"; USR_TEXT="$2"; shift;; --template) check_arg "$2"; USR_TEMPLATE="$2"; shift;; --template-dir) check_arg "$2"; USR_TEMPLATE_DIR="$2"; shift;; --var) check_arg "$2"; USR_METAVAR="$2"; shift;; --version) echo "NanoBlogger $VERSION"; exit;; --no-preview) NOPREVIEW_WEBLOG=1;; --no-publish) NOPUBLISH_WEBLOG=1;; -b|--blog-dir) check_arg "$2"; USR_BLOGDIR="$2"; shift;; -f|--force) FORCE_UPDATE=1; UPDATECACHE_WEBLOG=1;; -h|--help|help) show_help; exit;; -i|--interactive) check_arg "$2"; USR_INTERACTIVE="$2"; shift;; -v|--verbose) check_arg "$2"; VERBOSE="$2"; shift;; --) shift; break;; *) sanity_check echo "$main_badopts $bad_argument"; echo "$main_panic" exit 1 ;; esac shift done # post-processing for all command line args if [ "$CONFIG_WEBLOG" = 1 ]; then check_config; config_weblog [ "$RESORT_DATABASE" = 1 ] && resort_database fi if [ "$ADD_WEBLOG" = 1 ]; then add_weblog fi if [ "$DELETE_WEBLOG" = 1 ]; then check_config; delete_weblog fi if [ "$DRAFT_WEBLOG" = 1 ]; then check_config; nb_draft fi if [ "$EDIT_WEBLOG" = 1 ]; then check_config; edit_weblog fi if [ "$LIST_WEBLOG" = 1 ]; then check_config; list_weblog fi if [ "$MAKEPAGE_WEBLOG" = 1 ]; then check_config; weblog_page "$USR_MKPSRCFILE" "$USR_TEMPLATE" \ "$USR_MKPOUTFILE" fi if [ "$MAKEFILE_WEBLOG" = 1 ]; then check_config # don't overwrite existing files [ -f "$USR_MKFFILE" ] && die "'$USR_MKFFILE' - $samefilename" make_file "$USR_MKFFILE" "$USR_TEMPLATE" fi if [ "$MOVE_WEBLOG" = 1 ]; then check_config; cat_entry fi if [ "$UPDATECACHE_WEBLOG" = 1 ]; then USR_CACHEQUERY="$NB_QUERY" check_config; db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" update_cache "$USR_CACHEQUERY" "*" fi if [ "$UPDATE_WEBLOG" = 1 ]; then check_config; db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" build_weblog if [ "$PREVIEW_WEBLOG" = 1 ]; then check_config; preview_weblog fi if [ "$PUBLISH_WEBLOG" = 1 ]; then check_config; publish_weblog fi else if [ "$PREVIEW_WEBLOG" = 1 ]; then check_config; preview_weblog fi if [ "$PUBLISH_WEBLOG" = 1 ]; then check_config; publish_weblog fi fi exit 0 nanoblogger-3.4.2/nb.conf000644 000765 000024 00000002345 11336117757 015750 0ustar00kevinwstaff000000 000000 # NanoBlogger Global Config File # Last modified: 2007-01-04T14:47:26-05:00 # --- Misc. defaults --- # # Set the default language NB_LANG="en" # Set the default blog directory #BLOG_DIR="/var/www/weblog" # --- Blog Templates --- # # ALL templates must reside in the weblog's "templates" directory # e.g. [blog_dir]/templates ARCHIVE_INDEX_TEMPLATE="archive_index.htm" CATEGORY_TEMPLATE="category_archive.htm" MAIN_TEMPLATE="main_index.htm" MAKEPAGE_TEMPLATE="makepage.htm" YEAR_TEMPLATE="year_archive.htm" MONTH_TEMPLATE="month_archive.htm" DAY_TEMPLATE="day_archive.htm" PERMALINK_TEMPLATE="permalink.htm" MAINLINKS_TEMPLATE="main_links.htm" ENTRY_TEMPLATE="entry.htm" CATENTRY_TEMPLATE="category_entry.htm" MONTHENTRY_TEMPLATE="month_entry.htm" DAYENTRY_TEMPLATE="day_entry.htm" PERMALINKENTRY_TEMPLATE="permalink_entry.htm" METADATAFILE_TEMPLATE="file.metadata" METADATAENTRY_TEMPLATE="entry.metadata" # --- Data Files --- # # Set the default date command arguments used to create entry filenames #DB_DATEARGS="" # Set the default date format used to create and sort entry filenames # WARNING: do _not_ change unless you *know* what you're doing! # WARNING: changing this will probably break lib/database.sh #DB_DATEFORMAT="%Y-%m-%dT%H_%M_%S" nanoblogger-3.4.2/plugins/000755 000765 000024 00000000000 11336333422 016144 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/README000644 000765 000024 00000004366 11063754470 015363 0ustar00kevinwstaff000000 000000 # Last modified: 2008-09-11T22:14:32-04:00 NanoBlogger is a small weblog engine written in Bash for the command line. It uses common UNIX tools such as cat, grep, and sed to create static HTML content. Installing NanoBlogger ---------------------- 1. download gzipped tarball: http://nanoblogger.sourceforge.net/downloads/nanoblogger-xx.tar.gz 2. decompress gzipped tarball: tar xzf nanoblogger-xx.tar.gz 3. Modify shell's path to include the installation path.[1] NOTE: this step will be taken care for you when you install through a package manager, like apt-get. Generic Upgrade Instructions ---------------------------- Follow these three steps: 1. create a new weblog directory using nanoblogger (skip the configuration): nb --interactive 0 -b [new-blog-dir] add weblog 2. copy the old data directory over to the new weblog directory: cp -r [old-blog-dir]/data [new-blog-dir] 3. edit the new blog.conf to your likings and rebuild the weblog: nb -b [new-blog-dir] configure update all Upgrade Notes ------------- ### Style Sheets & Templates ### In addition to your *old* data directory, you will probably want to also copy over your styles and templates directory. If you decide to do this, you may find that your style sheets or templates no longer work as expected. In which case some adjustments will have to be made before they work properly with the new version. A side-by-side comparison between the old and new version will be your best recourse. Consider this a small trade-off for the ability to fully customize the weblog's appearance. ### Configuration ### Similarly, you will probably want to keep many settings from your old blog.conf. In which case, I suggest you do a side-by-side comparison of your old blog.conf and the new blog.conf. Then manually migrate your settings over to the new blog.conf. ### Plugins ### If you created your own plugins, please take into account any changes to variables, settings, etc., that your plugins may depend on. Final Notes ----------- For more in depth documentation please see the [NanoBlogger User Manual](nanoblogger.html) which should've been included with your copy of NanoBlogger. Project Page: http://nanoblogger.sourceforge.net Mailing List: http://groups.yahoo.com/group/nanoblogger nanoblogger-3.4.2/TODO000644 000765 000024 00000000302 11013670210 015135 0ustar00kevinwstaff000000 000000 * allow mutliple meta-variables to be defined from command line perhaps by way of meta-data file. * replace remaining references to categories with tags or combine in less confusing manner. nanoblogger-3.4.2/welcome-to-nb.txt000644 000765 000024 00000003715 11336333101 017674 0ustar00kevinwstaff000000 000000 TITLE: Welcome to NanoBlogger 3.4.2! AUTHOR: n1xt3r DATE: DESC: nanoblogger welcome message FORMAT: raw ----- BODY:

Welcome to NanoBlogger, a small weblog engine for the UNIX command line.

Quick Reference

  • create new weblog (directory) ... nb -b <blog_dir> add weblog
  • create new article ... nb add article
  • create new entry (w/o tag) ... nb add entry
  • create new tag ... nb add tag
  • tag new entry ... nb --tag [tag_id] add entry
  • list entries ... nb list <query>
  • list tags ... nb list tags
  • list entries by tag ... nb list tag [tag_id]
  • edit entry ... nb edit entry [entry_id]
  • tag entry ... nb --tag [tag_id] tag-entry [entry_id]
  • untag entry ... nb --tag [tag_id] delete entry [entry_id]
  • delete tag ... nb delete tag [tag_id]
  • delete entry ... nb delete entry [entry_id]
  • draft entry or article ... nb draft [draft_file]
  • import draft as entry ... nb import entry [draft_file]
  • import draft as article ... nb import article [draft_file]
  • update weblog ... nb update <all|DATE|main|max|articles|feeds>

<query> may equal all,tag,DATE or max (defaults to all)

Thank you for choosing NanoBlogger. Please direct comments and suggestions to the mailing list or submit a bug report to the project page over at sourceforge.net.

END----- nanoblogger-3.4.2/plugins/archive/000755 000765 000024 00000000000 11336333422 017565 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/atom.sh000644 000765 000024 00000016742 11336315547 017462 0ustar00kevinwstaff000000 000000 # NanoBlogger Atom Feed Plugin # synopsis: nb query feed [tag N] update # concatenate modification variables FEEDMOD_VAR="$New_EntryFile$Edit_EntryFile$Delete_EntryFile$Cat_EntryFile$USR_TITLE" # set URL for syndication feed [ ! -z "$BLOG_URL" ] && : ${BLOG_FEED_URL:=$BLOG_URL} # use entry excerpts from entry excerpts plugin # (excerpts plugin must be enabled to work) : ${ENTRY_EXCERPTS:=0} # set timezone used for feed : ${BLOG_FEED_TZD:=$BLOG_TZD} # limit number of items to include in feed # backwards support for deprecated FEED_ITEMS : ${BLOG_FEED_ITEMS:=$FEED_ITEMS} : ${BLOG_FEED_ITEMS:=10} : ${ATOM_ITEMS:=$BLOG_FEED_ITEMS} # build atom feeds for categories (0/1 = off/on) : ${ATOM_CATFEEDS:=0} # Atom 1.0 CSS support if [ -f "$BLOG_DIR/styles/feed.css" ] && [ -z "$BLOG_FEED_CSS" ]; then BLOG_FEED_CSS="styles/feed.css" fi # filename of atom feed NB_AtomFile="atom.$NB_SYND_FILETYPE" # atom feed version NB_AtomVer="1.0" # atom feed unique id (should be IRI as defined by RFC3987) NB_AtomID="$BLOG_FEED_URL/" NB_AtomModDate=`date "+%Y-%m-%dT%H:%M:%S${BLOG_FEED_TZD}"` # set link to the archives NB_AtomArchivesPath="$BLOG_FEED_URL/$ARCHIVES_DIR/" # set link for main template set_baseurl './' NB_AtomFeedLink='Atom' # set language of atom feed # unfortunately BLOG_FEED_LANG is useless here : ${ATOM_FEED_LANG:=en} # watch and reset chronological order if [ "$CHRON_ORDER" != 1 ]; then RESTORE_SORTARGS="$SORT_ARGS" SORT_ARGS="-ru" else RESTORE_SORTARGS= fi if [ ! -z "$FEEDMOD_VAR" ] || case "$NB_QUERY" in \ all) ! [[ "$NB_UPDATE" == *arch ]];; \ feed|feed[a-z]) :;; *) [ 1 = false ];; \ esac; then # transform relative links for the entries set_baseurl "$BLOG_FEED_URL/" # escape special characters to help create valid xml feeds esc_chars(){ sed -e '/[\&][ ]/ s//\& /g; /[\"]/ s//\"/g' } BLOG_FEED_TITLE=`echo "$BLOG_TITLE" |esc_chars` BLOG_FEED_SUBTITLE=`echo "$BLOG_DESCRIPTION" |esc_chars` NB_AtomAuthor=`echo "$BLOG_AUTHOR" |esc_chars` # make atom feed make_atomfeed(){ MKPAGE_OUTFILE="$1" mkdir -p `dirname "$MKPAGE_OUTFILE"` BLOG_FEED_URLFILE="$BLOG_FEED_URL/$NB_AtomFile" NB_AtomTitle="$BLOG_FEED_TITLE" NB_AtomSubtitle="$BLOG_FEED_SUBTITLE" [ ! -z "$NB_AtomCatTitle" ] && NB_AtomTitle="$template_catarchives $NB_AtomCatTitle | $BLOG_FEED_TITLE" [ ! -z "$NB_AtomCatLink" ] && BLOG_FEED_URLFILE="$BLOG_FEED_URL/$ARCHIVES_DIR/$NB_AtomCatFile" # Atom 1.0 support for icons and logos if [ ! -z "$BLOG_FEED_ICON" ]; then NB_AtomIcon=''$BLOG_FEED_URL/$BLOG_FEED_ICON'' fi if [ ! -z "$BLOG_FEED_LOGO" ]; then NB_AtomLogo=''$BLOG_FEED_URL/$BLOG_FEED_LOGO'' fi cat > "$MKPAGE_OUTFILE" <<-EOF $NB_AtomIcon $NB_AtomLogo $NB_AtomTitle $NB_AtomSubtitle $NB_AtomModDate $NB_AtomAuthor $BLOG_FEED_URL $NB_AtomID NanoBlogger $NB_AtomEntries EOF nb_msg "$MKPAGE_OUTFILE" # load makepage tidy plugin load_plugins makepage/tidy.sh NB_AtomTitle= } # generate feed entries build_atomfeed(){ db_catquery="$1" query_db all "$db_catquery" limit "$ATOM_ITEMS" ARCHIVE_LIST=(${DB_RESULTS[@]}) > "$SCRATCH_FILE".atomfeed for entry in ${ARCHIVE_LIST[@]}; do set_entrylink "$entry" load_entry "$NB_DATA_DIR/$entry" ALL Atom_EntryTime=`echo "$entry" |sed -e '/\_/ s//\:/g; s/[\.]'$NB_DATATYPE'//g'` Atom_EntryDate=`echo "$Atom_EntryTime${BLOG_FEED_TZD}"` # non-portable find command! #Atom_EntryModDate=`find "$NB_DATA_DIR/$entry" -printf "%TY-%Tm-%TdT%TH:%TM:%TS${BLOG_FEED_TZD}"` Atom_EntryModDate="$Atom_EntryDate" Atom_EntryTitle=`echo "$NB_EntryTitle" |esc_chars` Atom_EntryAuthor=`echo "$NB_EntryAuthor" |esc_chars` [ -z "$Atom_EntryTitle" ] && Atom_EntryTitle="$notitle" # support for Atom 1.0 enclosures (requires 'du' system command for determing length) read_metadata ENCLOSURE "$NB_DATA_DIR/$entry"; NB_AtomTempEnclosure="$METADATA" Atom_EntryCategory=; cat_title= > "$SCRATCH_FILE".atomfeed-cat atomentry_wcatids=`grep "$entry" "$NB_DATA_DIR/master.$NB_DBTYPE"` atomentry_catids="${atomentry_wcatids##*\>}" [ "$atomentry_wcatids" = "$atomentry_catids" ] && atomentry_catids= for atomentry_catdb in ${atomentry_catids//\,/ }; do cat_title=`nb_print "$NB_DATA_DIR"/cat_"$atomentry_catdb.$NB_DBTYPE" 1` cat_title=`echo "${cat_title##\,}" |esc_chars` if [ ! -z "$cat_title" ]; then cat >> "$SCRATCH_FILE".atomfeed-cat <<-EOF EOF fi done Atom_EntryCategory=$(< "$SCRATCH_FILE".atomfeed-cat) if [ "$ENTRY_EXCERPTS" = 1 ] && [ ! -z "$NB_EntryExcerpt" ]; then #Atom_EntryExcerpt=`echo "$NB_EntryExcerpt" |esc_chars` Atom_EntryExcerpt="$NB_EntryExcerpt" else #Atom_EntryExcerpt=`echo "$NB_MetaBody" |esc_chars` Atom_EntryExcerpt="$NB_MetaBody" fi Atom_EntryEnclosure=; # initialize variable # dissect ENCLOSURE metadata if [ ! -z "$NB_AtomTempEnclosure" ]; then Enclosure_File=`echo "$NB_AtomTempEnclosure" |cut -d' ' -f 1` Enclosure_Type=`echo "$NB_AtomTempEnclosure" |cut -d' ' -f 2` [ -z "$Enclosure_Type" ] || [ "$Enclosure_Type" = "$Enclosure_File" ] && Enclosure_Type="audio/mpeg" if [ -f "$BLOG_DIR/$Enclosure_File" ]; then Enclosure_Length=`du -b "$BLOG_DIR/$Enclosure_File" |sed -e '/[[:space:]].*$/ s///g'` Atom_EntryEnclosure='' fi fi cat >> "$SCRATCH_FILE".atomfeed <<-EOF $Atom_EntryTitle $Atom_EntryAuthor $Atom_EntryEnclosure ${NB_AtomArchivesPath}$NB_EntryPermalink $Atom_EntryDate $Atom_EntryModDate $Atom_EntryCategory
$Atom_EntryExcerpt
EOF done NB_AtomEntries=$(< "$SCRATCH_FILE".atomfeed) } # generate cat feed entries build_atom_catfeeds(){ db_categories=(${CAT_LIST[@]}) if [ ! -z "${db_categories[*]}" ]; then for cat_db in ${db_categories[@]}; do if [ -f "$NB_DATA_DIR/$cat_db" ]; then set_catlink "$cat_db" NB_AtomCatTitle=`nb_print "$NB_DATA_DIR/$cat_db" 1 |esc_chars` NB_AtomCatFile=`echo "$category_file" |sed -e 's/[\.]'$NB_FILETYPE'/-atom.'$NB_SYND_FILETYPE'/g'` NB_AtomCatLink="$category_link" nb_msg "$plugins_action $category_dir atom $NB_AtomVer feed ..." build_atomfeed "$cat_db" make_atomfeed "$BLOG_DIR/$ARCHIVES_DIR/$NB_AtomCatFile" fi done fi } nb_msg "$plugins_action atom $NB_AtomVer feed ..." build_atomfeed nocat make_atomfeed "$BLOG_DIR/$NB_AtomFile" if [ "$CATEGORY_FEEDS" = 1 ] && [ "$ATOM_CATFEEDS" = 1 ]; then build_atom_catfeeds fi fi # restore chronological order [ ! -z "$RESTORE_SORTARGS" ] && SORT_ARGS="$RESTORE_SORTARGS" nanoblogger-3.4.2/plugins/calendar.sh000644 000765 000024 00000006506 11237661541 020266 0ustar00kevinwstaff000000 000000 # NanoBlogger Calendar Plugin, requires the cal command. # converts the output of cal to an HTML Table and creates links of entries # # sample code for template - based off default stylesheet # #
# $NB_Calendar #
make_calendar(){ cal_year="$1" cal_month="$2" cal_file="$3" : ${CAL_CMD:=cal} mkdir -p `dirname "$cal_file"` # halt if cal command fails nb_eval "$CAL_CMD" || continue PLUGIN_CALENDAR=1 [ -z "$cal_year" ] && cal_year=`date +%Y` [ -z "$cal_month" ] && cal_month=`date +%m` query_cal=$cal_year.$cal_month [ ! -z "$DATE_LOCALE" ] && CALENDAR=`LC_ALL="$DATE_LOCALE" $CAL_CMD $CAL_ARGS "$cal_month" "$cal_year"` [ -z "$DATE_LOCALE" ] && CALENDAR=`$CAL_CMD $CAL_ARGS "$cal_month" "$cal_year"` CAL_HEAD=`echo "$CALENDAR" |sed 1q` CAL_HEAD=${CAL_HEAD//[ ][ ]/}; CAL_HEAD=${CAL_HEAD%%[ ][ ]}; CAL_HEAD=${CAL_HEAD##[ ][ ]} WEEK_DAYS=(`echo "$CALENDAR" |sed -n 2p`) DAYS=`echo "$CALENDAR" |sed 1,2d` NUM_DAY_LINES=(`echo "$DAYS" |grep -n "[0-9]" |cut -d":" -f 1`) nb_msg "$plugins_action weblog calendar for $CAL_HEAD ..." [[ "$cal_file" = "$BLOG_DIR/$PARTS_DIR/cal.$NB_FILETYPE" ]] && set_baseurl "./" query_db "$query_cal" CALMONTH_LIST=(${DB_RESULTS[*]}) echo '' > "$cal_file" if [ "$MONTH_ARCHIVES" = 1 ] && [ "${#CALMONTH_LIST[*]}" -gt 0 ]; then # create link to month's archive set_monthlink ${query_cal//\./-} echo '' >> "$cal_file" else echo '' >> "$cal_file" fi echo '' >> "$cal_file" for wd in ${WEEK_DAYS[@]}; do echo '' >> "$cal_file" done echo '' >> "$cal_file" for line in ${NUM_DAY_LINES[@]}; do DN_LINES=`echo "$DAYS" |sed -n "$line"p` echo '' >> "$cal_file" DNLINES_ENDSPACE=`echo "$DN_LINES" |grep -c ' $'` [ "$DNLINES_ENDSPACE" -lt 1 ] && echo "$DN_LINES" | sed -e '/ [ \t]/ s//' >> "$cal_file" fi done if [ "$set_link" != 1 ] ; then echo '' >> "$cal_file" fi done DNLINES_BEGINSPACE=`echo "$DN_LINES" |grep -c '^ '` [ "$DNLINES_BEGINSPACE" -lt 1 ] && echo "$DN_LINES" | sed -e '/ [ \t]/ s//' >> "$cal_file" done echo '
'$CAL_HEAD''$CAL_HEAD'
'$wd'
<\/td>\ /g; /[0-9]/ s///g; / $/ s///g' >> "$cal_file" for dn in $DN_LINES; do set_link=0 CALENTRY_LIST=(`for day in ${CALMONTH_LIST[@]}; do echo $day; done |grep $dn`) for entry in ${CALENTRY_LIST[@]}; do entry_year=${entry:0:4} entry_month=${entry:5:2} entry_day=${entry:8:2} entry_day=`echo $entry_day |sed -e '/^0/ s///g'` if [ "$cal_year$cal_month$dn" = "$entry_year$entry_month$entry_day" ] ; then set_link=1 NB_EntryID=$x_id${entrylink_var//[\/]/-} if [ "$MONTH_ARCHIVES" != 1 ] && [ "$ENTRY_ARCHIVES" = 1 ]; then set_entrylink "$entry" else set_entrylink "$entry" altlink fi dn=''$dn'' echo ''$dn''$dn'<\/td>\ /g; /[0-9]/ s///g; /^ / s///g' >> "$cal_file" echo '
' >> "$cal_file" CALENDAR= } make_calendar "`date +%Y`" "`date +%m`" "$BLOG_DIR/$PARTS_DIR/cal.$NB_FILETYPE" # The main calendar's place-holder for the templates NB_Calendar=$(< "$BLOG_DIR/$PARTS_DIR/cal.$NB_FILETYPE") nanoblogger-3.4.2/plugins/entry/000755 000765 000024 00000000000 11336333422 017305 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/makepage/000755 000765 000024 00000000000 11336333422 017716 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/page/000755 000765 000024 00000000000 11336333423 017061 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/post/000755 000765 000024 00000000000 11336333422 017131 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/recent_entries.sh000644 000765 000024 00000003456 10744505253 021526 0ustar00kevinwstaff000000 000000 # NanoBlogger Recent Entries List Plugin # List Recent entries # # sample code for templates, based off the default stylesheet # #
# Recent Entries/Alternate Entries #
#
# $NB_Recent_Entries/$NB_Alterate_Entries #
# set how many entries to list : ${RECENTLIST_ENTRIES:=10} : ${RECENTLIST_OFFSET:=1} : ${RECENTLIST_QUERYMODE:=max} PLUGIN_OUTFILE1="$BLOG_DIR/$PARTS_DIR/recent_entries.$NB_FILETYPE" PLUGIN_OUTFILE2="$BLOG_DIR/$PARTS_DIR/alternate_entries.$NB_FILETYPE" # always sort in reverse chronological order so recent entries # stay near the top of the list if [ "$CHRON_ORDER" != 1 ]; then RECENTLIST_SORTARGS="-ru" else RECENTLIST_SORTARGS= fi nb_msg "$plugins_action recent entries links ..." set_baseurl "./" get_entries(){ case "$1" in new) query_db "$RECENTLIST_QUERYMODE" nocat limit "$RECENTLIST_ENTRIES" "" "$RECENTLIST_SORTARGS" ;; alt) let XRECENTLIST_OFFSET=${RECENTLIST_ENTRIES}+1 XRECENTLIST_ENTRIES=$RECENTLIST_ENTRIES query_db "$RECENTLIST_QUERYMODE" nocat limit "$XRECENTLIST_ENTRIES" "$XRECENTLIST_OFFSET" "$RECENTLIST_SORTARGS" ;; esac RECENTLIST_DBRESULTS=(${DB_RESULTS[*]}) for entry in ${RECENTLIST_DBRESULTS[*]}; do # 1st try to get title from set_entrylink instance of read_metadata link_title="$smartlink_metatitle" if [ -z "$link_title" ]; then read_metadata TITLE "$NB_DATA_DIR/$entry" link_title="$METADATA" fi NB_EntryID=$x_id${entrylink_var//[\/]/-} [ -z "$link_title" ] && link_title="$notitle" set_entrylink "$entry" echo ''$link_title'
' done } get_entries new > "$PLUGIN_OUTFILE1" NB_RecentEntries=$(< "$PLUGIN_OUTFILE1") # uncomment to create alternate entry listing #get_entries alt > "$PLUGIN_OUTFILE2" #NB_AlternateEntries=$(< "$PLUGIN_OUTFILE2") nanoblogger-3.4.2/plugins/rss2.sh000644 000765 000024 00000016526 11336315547 017413 0ustar00kevinwstaff000000 000000 # NanoBlogger RSS 2.0 Feed Plugin # synopsis: nb query feed [tag N] update # concatenate modification variables FEEDMOD_VAR="$New_EntryFile$Edit_EntryFile$Delete_EntryFile$Cat_EntryFile$USR_TITLE" # set URL for syndication feed [ ! -z "$BLOG_URL" ] && : ${BLOG_FEED_URL:=$BLOG_URL} # use entry excerpts from entry excerpts plugin # (excerpts plugin must be enabled to work) : ${ENTRY_EXCERPTS:=0} # set timezone used for feed : ${BLOG_FEED_TZD:=$BLOG_TZD} # limit number of items to include in feed # backwards support for deprecated FEED_ITEMS : ${BLOG_FEED_ITEMS:=$FEED_ITEMS} : ${BLOG_FEED_ITEMS:=10} : ${RSS2_ITEMS:=$BLOG_FEED_ITEMS} # build rss2 feeds for categories (0/1 = off/on) : ${RSS2_CATFEEDS:=0} # RSS 2.0 CSS support if [ -f "$BLOG_DIR/styles/feed.css" ] && [ -z "$BLOG_FEED_CSS" ]; then BLOG_FEED_CSS="styles/feed.css" fi # output filename of rss feed NB_RSS2File="rss.$NB_SYND_FILETYPE" # rss version NB_RSS2Ver="2.0" NB_RSS2ModDate=`date "+%Y-%m-%dT%H:%M:%S${BLOG_FEED_TZD}"` # set link to archives NB_RSS2ArchivesPath="$BLOG_FEED_URL/$ARCHIVES_DIR/" # set link for main template set_baseurl './' NB_RSS2FeedLink='RSS' # backwards support for deprecated BLOG_LANG : ${BLOG_FEED_LANG:=$BLOG_LANG} # watch and reset chronological order if [ "$CHRON_ORDER" != 1 ]; then RESTORE_SORTARGS="$SORT_ARGS" SORT_ARGS="-ru" else RESTORE_SORTARGS= fi if [ ! -z "$FEEDMOD_VAR" ] || case "$NB_QUERY" in \ all) ! [[ "$NB_UPDATE" == *arch ]];; \ feed|feed[a-z]) :;; *) [ 1 = false ];; \ esac; then # transform relative links for the entries set_baseurl "$BLOG_FEED_URL/" # escape special characters to help create valid xml feeds esc_chars(){ sed -e '/[\&][ ]/ s//\& /g; /[\"]/ s//\"/g' } BLOG_FEED_TITLE=`echo "$BLOG_TITLE" |esc_chars` NB_RSS2Author=`echo "$BLOG_AUTHOR" |esc_chars` # make rss feed make_rssfeed(){ MKPAGE_OUTFILE="$1" mkdir -p `dirname "$MKPAGE_OUTFILE"` BLOG_FEED_URLFILE="$BLOG_FEED_URL/$NB_RSS2File" NB_RSS2Title="$BLOG_FEED_TITLE" [ ! -z "$NB_RSS2CatTitle" ] && NB_RSS2Title="$template_catarchives $NB_RSS2CatTitle | $BLOG_FEED_TITLE" if [ ! -z "$NB_RSS2CatLink" ]; then NB_RSS2File="$ARCHIVES_DIR/$NB_RSS2CatFile" BLOG_FEED_URLFILE="$BLOG_FEED_URL/$NB_RSS2File" fi # RSS 2.0 support for icons/logos # use syndication logo for when no icon is set : ${BLOG_FEED_ICON:=$BLOG_FEED_LOGO} if [ ! -z "$BLOG_FEED_ICON" ]; then NB_RSS2Logo=''$BLOG_FEED_URL''$BLOG_FEED_URL'/'$BLOG_FEED_ICON''$NB_RSS2Title'' fi cat > "$MKPAGE_OUTFILE" <<-EOF $NB_RSS2Title $BLOG_FEED_URL $BLOG_DESCRIPTION $BLOG_FEED_LANG $NB_RSS2Author $NB_RSS2ModDate $NB_RSS2Logo $NB_RSS2Entries EOF nb_msg "$MKPAGE_OUTFILE" # load makepage tidy plugin load_plugins makepage/tidy.sh NB_RSS2Title= } # generate feed entries build_rssfeed(){ db_catquery="$1" query_db all "$db_catquery" limit "$RSS2_ITEMS" ARCHIVE_LIST=(${DB_RESULTS[@]}) > "$SCRATCH_FILE".rss2feed for entry in ${ARCHIVE_LIST[@]}; do NB_RSS2EntryTime=`echo "$entry" |sed -e '/\_/ s//\:/g; s/[\.]'$NB_DATATYPE'//g'` set_entrylink "$entry" load_entry "$NB_DATA_DIR/$entry" ALL # non-portable find command! sets RFC822 date for pubDate #NB_RSS2EntryModDate=`find "$NB_DATA_DIR/$entry" -printf "%Ta, %Td %Tb %TY %TH:%TM:%TS %Tz\n"` NB_RSS2EntryTitle=`echo "$NB_EntryTitle" |esc_chars` NB_RSS2EntryAuthor=`echo "$NB_EntryAuthor" |esc_chars` [ -z "$NB_RSS2EntryTitle" ] && NB_RSS2EntryTitle="$notitle" NB_RSS2EntrySubject=; cat_title=; oldcat_title= # support for RSS 2.0 enclosures (requires 'du' system command for determing length) read_metadata ENCLOSURE "$NB_DATA_DIR/$entry"; NB_RSS2TempEnclosure="$METADATA" rss2entry_wcatids=`grep "$entry" "$NB_DATA_DIR/master.$NB_DBTYPE"` rss2entry_catids="${rss2entry_wcatids##*\>}" [ "$rss2entry_wcatids" = "$rss2entry_catids" ] && rss2entry_catids= for rss2_catnum in ${rss2entry_catids//\,/ }; do cat_title=`nb_print "$NB_DATA_DIR"/cat_"$rss2_catnum.$NB_DBTYPE" 1` [ "$cat_title" != "$oldcat_title" ] && cat_title="$oldcat_title $cat_title" oldcat_title="$cat_title," done if [ ! -z "$cat_title" ]; then cat_title=`echo "${cat_title##\,}" |esc_chars` NB_RSS2EntrySubject=`echo ''$cat_title''` fi if [ "$ENTRY_EXCERPTS" = 1 ] && [ ! -z "$NB_EntryExcerpt" ]; then #NB_RSS2EntryExcerpt=`echo "$NB_EntryExcerpt" |esc_chars` NB_RSS2EntryExcerpt="$NB_EntryExcerpt" else #NB_RSS2EntryExcerpt=`echo "$NB_MetaBody" |esc_chars` NB_RSS2EntryExcerpt="$NB_MetaBody" fi # for escaped text/html only # NB_RSS2EntryEnclosure=; # initialize variable # dissect ENCLOSURE metadata if [ ! -z "$NB_RSS2TempEnclosure" ]; then Enclosure_File=`echo "$NB_RSS2TempEnclosure" |cut -d' ' -f 1` Enclosure_Type=`echo "$NB_RSS2TempEnclosure" |cut -d' ' -f 2` [ -z "$Enclosure_Type" ] || [ "$Enclosure_Type" = "$Enclosure_File" ] && Enclosure_Type="audio/mpeg" if [ -f "$BLOG_DIR/$Enclosure_File" ]; then Enclosure_Length=`du -b "$BLOG_DIR/$Enclosure_File" |sed -e '/[[:space:]].*$/ s///g'` NB_RSS2EntryEnclosure='' fi fi cat >> "$SCRATCH_FILE".rss2feed <<-EOF ${NB_RSS2ArchivesPath}$NB_EntryPermalink ${NB_RSS2ArchivesPath}$NB_EntryPermalink $NB_RSS2EntryTitle $NB_RSS2EntryTime${BLOG_FEED_TZD} $NB_RSS2EntryAuthor $NB_RSS2EntrySubject $NB_RSS2EntryEnclosure EOF done NB_RSS2Entries=$(< "$SCRATCH_FILE".rss2feed) } # generate category feed entries build_rss_catfeeds(){ db_categories=(${CAT_LIST[@]}) if [ ! -z "${db_categories[*]}" ]; then for cat_db in ${db_categories[@]}; do if [ -f "$NB_DATA_DIR/$cat_db" ]; then set_catlink "$cat_db" NB_RSS2CatFile=`echo "$category_file" |sed -e 's/[\.]'$NB_FILETYPE'/-rss.'$NB_SYND_FILETYPE'/g'` NB_RSS2CatLink="$category_link" NB_RSS2CatTitle=`nb_print "$NB_DATA_DIR/$cat_db" 1 |esc_chars` nb_msg "$plugins_action $category_dir rss $NB_RSS2Ver feed ..." build_rssfeed "$cat_db" make_rssfeed "$BLOG_DIR/$ARCHIVES_DIR/$NB_RSS2CatFile" fi done fi } nb_msg "$plugins_action rss $NB_RSS2Ver feed ..." build_rssfeed nocat make_rssfeed "$BLOG_DIR/$NB_RSS2File" if [ "$CATEGORY_FEEDS" = 1 ] && [ "$RSS2_CATFEEDS" = 1 ]; then build_rss_catfeeds fi fi # restore chronological order [ ! -z "$RESTORE_SORTARGS" ] && SORT_ARGS="$RESTORE_SORTARGS" nanoblogger-3.4.2/plugins/shortcode/000755 000765 000024 00000000000 11336333422 020136 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/weblog_links.sh000644 000765 000024 00000015546 11336315547 021202 0ustar00kevinwstaff000000 000000 # Nanoblogger Plugin: Weblog Links # Last modified: 2010-02-15T01:42:38-05:00 #
# Links #
# #
# $NB_MainLinks #
#
# Categories #
# #
# $NB_CategoryLinks #
#
# Archives #
# #
# $NB_MonthLinks #
# command used to filter order of category links : ${CATLINKS_FILTERCMD:=sort} # maximum number of months to show for $NB_MonthLinks # -1 = all : ${MAX_MONTHLINKS:=12} : ${ALL_MONTHLINKS:=0} # maximum number of years to show for $NB_YearLinks # -1 = all : ${MAX_YEARLINKS:=12} : ${ALL_YEARLINKS:=0} # validate MAX_MONTHLINKS (must be greater than 0) MONTHLINKS_NUMVAR=`echo "$MAX_MONTHLINKS" |grep -c "[0-9]"` [ "$MONTHLINKS_NUMVAR" = 0 ] && die "MAX_MONTHLINKS !> 0" # unlimited links if [ "$MAX_MONTHLINKS" = -1 ]; then ALL_MONTHLINKS="1" MAX_MONTHLINKS="1" fi # validate MAX_YEARLINKS (must be greater than 0) YEARLINKS_NUMVAR=`echo "$MAX_YEARLINKS" |grep -c "[0-9]"` [ "$YEARLINKS_NUMVAR" = 0 ] && die "MAX_YEARLINKS !> 0" # unlimited links if [ "$MAX_YEARLINKS" = -1 ]; then ALL_YEARLINKS="1" MAX_YEARLINKS="1" fi set_baseurl "./" nb_msg "$plugins_action weblog links ..." # create main set of links load_template "$NB_TEMPLATE_DIR/$MAINLINKS_TEMPLATE" NB_MainLinks="$TEMPLATE_DATA" # create links for categories build_catlinks(){ for bcat_link in ${db_categories[*]}; do if [ -f "$NB_DATA_DIR/$bcat_link" ]; then #cat_index=`chg_suffix "$bcat_link"` #cat_feed=`chg_suffix "$bcat_link" "$NB_SYND_FILETYPE"` set_catlink "$bcat_link" cat_index="$category_link" query_db "$db_query" "$bcat_link" cat_total=${#DB_RESULTS[*]} NB_CategoryTitle=`nb_print "$NB_DATA_DIR/$bcat_link" 1` cat <<-EOF $NB_CategoryTitle ($cat_total)
EOF fi done } # get total number of years and tally total months from MAX_YEARLINKS [ -z "${YEAR_DB_RESULTS[*]}" ] && query_db years total_nyears=${#YEAR_DB_RESULTS[*]} NYEARS=(`for nyear in ${YEAR_DB_RESULTS[*]}; do echo $nyear; done |sed "$MAX_YEARLINKS"q`) month_tally=0 for query_nyear in ${NYEARS[*]}; do query_db "$query_nyear" months_nyear=${#DB_RESULTS[*]} [ "$months_nyear" -gt 0 ] && let month_tally=${month_tally}+$months_nyear done # get total number of months and tally total entries from MAX_MONTHLINKS [ -z "${MONTH_DB_RESULTS[*]}" ] && query_db months total_nmonths=${#MONTH_DB_RESULTS[*]} NMONTHS=(`for nmonth in ${MONTH_DB_RESULTS[*]}; do echo $nmonth; done |sed "$MAX_MONTHLINKS"q`) entry_tally=0 for query_nmonth in ${NMONTHS[*]}; do query_db "$query_nmonth" entries_nmonth=${#DB_RESULTS[*]} [ "$entries_nmonth" -gt 0 ] && let entry_tally=${entry_tally}+$entries_nmonth done build_catlinks |$CATLINKS_FILTERCMD |sed -e 's///' > "$BLOG_DIR/$PARTS_DIR/cat_links.$NB_FILETYPE" NB_CategoryLinks=$(< "$BLOG_DIR/$PARTS_DIR/cat_links.$NB_FILETYPE") [ -z "$NB_CategoryLinks" ] && NB_CategoryLinks="$categories_nolist" # create links to feeds # TODO: include RSS 1.0 feeds or just forget about them? if [[ ! -z "$NB_RSS2Ver" && ! -z "$NB_AtomVer" ]]; then NB_BlogFeeds="$template_syndicate_main ($NB_RSS2FeedLink, $NB_AtomFeedLink)
" elif [[ ! -z "$NB_RSS2Ver" && -z "$NB_AtomVer" ]]; then NB_BlogFeeds="$template_syndicate_main ($NB_RSS2FeedLink)
" elif [[ -z "$NB_RSS2Ver" && ! -z "$NB_AtomVer" ]]; then NB_BlogFeeds="$template_syndicate_main ($NB_AtomFeedLink)
" fi if [ "$CATEGORY_FEEDS" = 1 ]; then if [[ "$ATOM_CATFEEDS" = 1 && "$RSS2_CATFEEDS" = 1 ]]; then # TODO: find a better way to check if atom or rss feeds exist before adding them blindly sed 's@\([^<]*\).*@\3 (RSS, Atom)
@' "$BLOG_DIR/$PARTS_DIR/cat_links.$NB_FILETYPE" > "$BLOG_DIR/$PARTS_DIR/cat_feeds.$NB_FILETYPE" NB_CategoryFeeds=$(< "$BLOG_DIR/$PARTS_DIR/cat_feeds.$NB_FILETYPE") elif [[ "$ATOM_CATFEEDS" = 1 && "$RSS2_CATFEEDS" != 1 ]]; then sed 's@\([^<]*\).*@\3 (Atom)
@' "$BLOG_DIR/$PARTS_DIR/cat_links.$NB_FILETYPE" > "$BLOG_DIR/$PARTS_DIR/cat_feeds.$NB_FILETYPE" NB_CategoryFeeds=$(< "$BLOG_DIR/$PARTS_DIR/cat_feeds.$NB_FILETYPE") elif [[ "$RSS2_CATFEEDS" = 1 && "$ATOM_CATFEEDS" != 1 ]]; then sed 's@\([^<]*\).*@\3 (RSS)
@' "$BLOG_DIR/$PARTS_DIR/cat_links.$NB_FILETYPE" > "$BLOG_DIR/$PARTS_DIR/cat_feeds.$NB_FILETYPE" NB_CategoryFeeds=$(< "$BLOG_DIR/$PARTS_DIR/cat_feeds.$NB_FILETYPE") fi fi # helper to create links to year archives make_yearlink(){ NB_YearTitle="$yearlink" query_db "$yearlink" year_total=${#DB_RESULTS[*]} # following needs to fit on single line cat <<-EOF $NB_YearTitle ($year_total)
EOF } # cal command test to retrieve locale month titles [ -z "$CAL_CMD" ] && CAL_CMD="cal" $CAL_CMD > "$SCRATCH_FILE".cal_test 2>&1 && CAL_VAR="1" # tool to create monthly archive links make_monthlink(){ if [ "$CAL_VAR" = "1" ]; then [ ! -z "$DATE_LOCALE" ] && CALENDAR=`LC_ALL="$DATE_LOCALE" $CAL_CMD $CAL_ARGS $monthn $yearn` [ -z "$DATE_LOCALE" ] && CALENDAR=`$CAL_CMD $CAL_ARGS $monthn $yearn` Month_Title=`echo "$CALENDAR" |sed -e '/^[ ]*/ s///g; 1q'` else Month_Title="$month" fi month_total=${#DB_RESULTS[*]} set_monthlink "$month" cat <<-EOF $Month_Title ($month_total)
EOF } # create yearly archive links if [ "$ALL_YEARLINKS" = 1 ]; then query_db all else query_db all nocat limit $month_tally 1 fi YEARLINKS_LIST=(`for yearlink in ${DB_RESULTS[*]}; do echo $yearlink done |cut -c1-4 |sort $SORT_ARGS`) for yearlink in ${YEARLINKS_LIST[*]}; do make_yearlink done |sort $SORT_ARGS > "$BLOG_DIR/$PARTS_DIR/year_links.$NB_FILETYPE" # yearly archives continued if [ $ALL_YEARLINKS != 1 ] && [ $MAX_YEARLINKS -lt $total_nyears ]; then cat >> "$BLOG_DIR/$PARTS_DIR/year_links.$NB_FILETYPE" <<-EOF $NB_NextPage EOF fi NB_YearLinks=$(< "$BLOG_DIR/$PARTS_DIR/year_links.$NB_FILETYPE") # create monthly archive links if [ "$MONTH_ARCHIVES" = 1 ]; then if [ "$ALL_MONTHLINKS" = 1 ]; then query_db all else query_db all nocat limit $entry_tally 1 fi loop_archive "${DB_RESULTS[*]}" months make_monthlink |sort $SORT_ARGS > "$BLOG_DIR/$PARTS_DIR/month_links.$NB_FILETYPE" # monthly archives continued if [ $ALL_MONTHLINKS != 1 ] && [ $MAX_MONTHLINKS -lt $total_nmonths ]; then cat >> "$BLOG_DIR/$PARTS_DIR/month_links.$NB_FILETYPE" <<-EOF $NB_NextPage EOF fi NB_MonthLinks=$(< "$BLOG_DIR/$PARTS_DIR/month_links.$NB_FILETYPE") fi nanoblogger-3.4.2/plugins/weblog_status.sh000644 000765 000024 00000002743 11336117757 021403 0ustar00kevinwstaff000000 000000 # NanoBlogger Weblog Status Plugin # generate some misc. statistics about the weblog # # sample code for templates - based on default stylesheet # #
# Weblog Status #
#
# $NB_Blog_Status #
OUTPUT_FILE="$BLOG_DIR/$PARTS_DIR/weblog_status.$NB_FILETYPE" WEBLOGSTATUS_TEMPLATECOPY="$NB_BASE_DIR/default/templates/weblog_status.htm" WEBLOG_STATUSTEMPLATE="$NB_TEMPLATE_DIR/weblog_status.htm" nb_msg "$plugins_action weblog status ..." if [ ! -f "$WEBLOG_STATUSTEMPLATE" ] ; then # WEBLOG_STATUSTEMPLATE doesn't exist, get it from default cp "$WEBLOGSTATUS_TEMPLATECOPY" "$WEBLOG_STATUSTEMPLATE" || die "$nb_plugin: failed to copy '$WEBLOGSTATUS_TEMPLATECOPY!' please repair nanoblogger! goodbye." fi [ -r "$WEBLOG_STATUSTEMPLATE" ] || die "`basename $0`: '$WEBLOG_STATUSTEMPLATE' - missing template! goodbye." TOTAL_CATEGORIES=`for catdbs in "$NB_DATA_DIR"/cat_*."$NB_DBTYPE"; do echo $catdbs; done |grep -c "."` TOTAL_ENTRIES=`grep -c "." "$NB_DATA_DIR/master.$NB_DBTYPE"` LAST_ENTRY=`nb_print "$NB_DATA_DIR/master.$NB_DBTYPE" 1 |cut -d">" -f 1` if [ -f "$NB_DATA_DIR/$LAST_ENTRY" ]; then read_metadata DATE "$NB_DATA_DIR/$LAST_ENTRY" LAST_ENTRY_TIME="$METADATA" else LAST_ENTRY_TIME="" fi LAST_UPDATED=`filter_dateformat "$DATE_FORMAT"` NB_BlogStatus=$(< "$WEBLOG_STATUSTEMPLATE") cat > "$OUTPUT_FILE" <<-EOF cat <<-TMPL $NB_BlogStatus TMPL EOF NB_BlogStatus=$(. "$OUTPUT_FILE") cat > "$OUTPUT_FILE" <<-EOF $NB_BlogStatus EOF nanoblogger-3.4.2/plugins/z001_articles_meta.sh000644 000765 000024 00000011520 11063754470 022074 0ustar00kevinwstaff000000 000000 # NanoBlogger Metadata Based Article Manager plugin # How it works: # Looks for .txt files in multiple directories. # Loads metafile (use --draft to create). # Creates the article using the makepage.htm template. # Reads alternate title for list from $ARTICLES_TITLE_FILE (1st line). # Adds links to NB_ArticleLinks. # sample code for templates, based off the default stylesheet # # $NB_ArticleLinks # set BASE_URL for links to $ATCLSECTION_DIR set_baseurl "./" # space seperated list of sub-directories inside $BLOG_DIR, where articles are located set_articleconf(){ # e.g. ARTICLES_DIR="articles stories poems long\ name\ with\ spaces" : ${ARTICLES_DIR:=articles} : ${ARTICLES_SUFFIX:=txt} : ${ARTICLES_TEMPLATE:=$NB_TEMPLATE_DIR/$MAKEPAGE_TEMPLATE} : ${ARTICLES_FILTERCMD:=sort} : ${ARTICLES_TITLE_FILE:=.articles_title.txt} : ${ARTICLES_FORMAT:=$PAGE_FORMAT} } # reset basic configs to allow for multiple article configs reset_articleconf(){ ARTICLES_SUFFIX=; ARTICLES_TEMPLATE=; ARTICLES_FORMAT= set_articleconf } ARTICLE_PLUGIN_OUTFILE="$BLOG_DIR/$PARTS_DIR/article_links.$NB_FILETYPE" set_articlelink(){ articlelink_var="$1" #article_title=`sed 1q "$BLOG_DIR/$ATCLSECTION_DIR/$articlelink_var"` read_metadata TITLE "$BLOG_DIR/$ATCLSECTION_DIR/$articlelink_var" if [ -z "$METADATA" ]; then article_title="$notitle" else article_title="${METADATA//\-/–}" fi # new way article_name=`echo "$articlelink_var" |cut -d"." -f 1` article_dir=`translit_text "$article_name"` article_file="$article_dir/index.$NB_FILETYPE" article_link="$article_dir/$NB_INDEX" # old way #article_file=`chg_suffix "$articlelink_var"` #article_link="$article_file" } addalist_name(){ NB_ArticlesListTitle= # Reads alternate title for list from $ARTICLES_TITLE_FILE (1st line). [ -f "$BLOG_DIR/$ATCLSECTION_DIR/$ARTICLES_TITLE_FILE" ] && NB_ArticlesListTitle=`nb_print $BLOG_DIR/$ATCLSECTION_DIR/$ARTICLES_TITLE_FILE 1` # let ARTCLSECTION_DIR define root of articles directory until # alternate title is created, else create a subtitle for the list if [ "$ATCLSECTION_DIR" != `echo "$ARTICLES_DIR" |cut -d" " -f 1` ] || [ ! -z "$NB_ArticlesListTitle" ]; then if [ ! -f "$BLOG_DIR/$ATCLSECTION_DIR/$ARTICLES_TITLE_FILE" ]; then basename "$BLOG_DIR/$ATCLSECTION_DIR" > "$BLOG_DIR/$ATCLSECTION_DIR/$ARTICLES_TITLE_FILE" NB_ArticlesListTitle=`nb_print $BLOG_DIR/$ATCLSECTION_DIR/$ARTICLES_TITLE_FILE 1` fi [ -z "$NB_ArticlesListTitle" ] && NB_ArticlesListTitle="$ATCLSECTION_DIR" cat >> "$ARTICLE_PLUGIN_OUTFILE" <<-EOF
$NB_ArticlesListTitle
EOF fi NB_ArticlesListTitleHTML=$(< "$ARTICLE_PLUGIN_OUTFILE") > "$ARTICLE_PLUGIN_OUTFILE" } add_articlelink(){ echo ''$BLOGPAGE_TITLE'
' >> "$ARTICLE_PLUGIN_OUTFILE" } create_article(){ BLOGPAGE_SRCFILE="$BLOG_DIR/$ATCLSECTION_DIR/$article_srcfile" BLOGPAGE_OUTFILE="$BLOG_DIR/$ATCLSECTION_DIR/$article_file" case "$NB_QUERY" in all|article|article[a-z]) [ -z "$cat_num" ] && ! [[ "$NB_UPDATE" == *arch ]] && rm -f "$BLOGPAGE_OUTFILE" ;; *) : ;; esac if [ "$BLOGPAGE_SRCFILE" -nt "$BLOGPAGE_OUTFILE" ]; then # set text formatting for page content BLOGPAGE_FORMAT="$ARTICLES_FORMAT" weblog_page "$BLOGPAGE_SRCFILE" "$ARTICLES_TEMPLATE" "$BLOGPAGE_OUTFILE" fi } cycle_articles_for(){ build_part="$1" build_list=`cd "$BLOG_DIR/$ATCLSECTION_DIR"; for articles in *.$ARTICLES_SUFFIX; do echo "$articles"; done` [ "$build_list" = "*.$ARTICLES_SUFFIX" ] && build_list= article_lines=`echo "$build_list" |grep -n "." |cut -c1-2 |sed -e '/[\:\]/ s///g'` for line in ${article_lines[@]}; do article_line=`echo "$build_list" |sed -n "$line"p` article_srcfile=`echo "$article_line"` if [ -f "$BLOG_DIR/$ATCLSECTION_DIR/$article_srcfile" ]; then set_articlelink "$article_srcfile" BLOGPAGE_TITLE="$article_title" "$build_part" fi done } NB_ArticleLinks="$articles_nolist" > "$ARTICLE_PLUGIN_OUTFILE" set_articleconf for articles_pass in 1 2; do for ATCLSECTION_DIR in ${ARTICLES_DIR[@]}; do if [ -d "$BLOG_DIR/$ATCLSECTION_DIR" ]; then # load articles config file ARTICLE_CONF="$BLOG_DIR/$ATCLSECTION_DIR/article.conf" if [ -f "$ARTICLE_CONF" ]; then reset_articleconf . "$ARTICLE_CONF" fi if [ "$articles_pass" -lt 2 ]; then addalist_name cycle_articles_for add_articlelink NB_ArticleLinksHTML=`$ARTICLES_FILTERCMD "$ARTICLE_PLUGIN_OUTFILE"` cat > "$ARTICLE_PLUGIN_OUTFILE" <<-EOF $NB_ArticlesListTitleHTML
$NB_ArticleLinksHTML
EOF NB_ArticleLinks=$(< "$ARTICLE_PLUGIN_OUTFILE") else [ -d "$BLOG_DIR/$ATCLSECTION_DIR" ] && nb_msg "$plugins_action $plugins_articles: $BLOG_DIR/$ATCLSECTION_DIR ..." cycle_articles_for create_article fi fi done done # clear settings for some page plugins, like markdown.sh reset_articleconf nanoblogger-3.4.2/plugins/shortcode/baseurl.sh000644 000765 000024 00000002606 11101241013 022113 0ustar00kevinwstaff000000 000000 # NanoBlogger Base-URL Shortcode Plugin # converts [base-url] to relative path # # e.g. [base-url] -> "./" or "../" # quickly detect baseurl shortcode oldscode_baseurl_specified="${NB_MetaBody//*[\%]base\_url[\%]*/true}" shortcode_baseurl_specified="${NB_MetaBody//*[\[]base?url[\]]*/true}" # old shortocode for base-url # e.g. %base_url% -> "./" or "../" oldsc_baseurl_specified(){ if [ "$oldscode_baseurl_specified" = true ]; then shortcode_baseurl_output=; shortcode_baseurl_sedscript= # don't change BASE_URL of entries [ ! -z "$weblogpage_plugin" ] && set_baseurl "" "$BLOGPAGE_OUTFILE" baseurl_link="${BASE_URL//\//\\/}" shortcode_baseurl_output="$baseurl_link" shortcode_baseurl_sedscript='s/\%base\_url\%/'$shortcode_baseurl_output'/' NB_MetaBody=`echo "$NB_MetaBody" |sed -e "$shortcode_baseurl_sedscript"` fi } # shortocode for base-url sc_baseurl_specified(){ if [ "$shortcode_baseurl_specified" = true ]; then shortcode_baseurl_output=; shortcode_baseurl_sedscript= # don't change BASE_URL of entries [ ! -z "$weblogpage_plugin" ] && set_baseurl "" "$BLOGPAGE_OUTFILE" baseurl_link="${BASE_URL//\//\\/}" shortcode_baseurl_output="$baseurl_link" shortcode_baseurl_sedscript='s/\[base.url\]/'$shortcode_baseurl_output'/g' NB_MetaBody=`echo "$NB_MetaBody" |sed -e "$shortcode_baseurl_sedscript"` fi } for sc_baseurl in oldsc_baseurl_specified sc_baseurl_specified; do $sc_baseurl done nanoblogger-3.4.2/plugins/shortcode/moods.sh000644 000765 000024 00000002462 11102704437 021616 0ustar00kevinwstaff000000 000000 # NanoBlogger Moods Shortcode Plugin # converts mood variables into emoticons # - control using moods.conf file : ${MOODS_DIR:=$BLOG_DIR/moods} # don't change BASE_URL of entries [ ! -z "$weblogpage_plugin" ] && set_baseurl "" "$BLOGPAGE_OUTFILE" MOODS_URL="${BASE_URL}moods" MOODS_CONF="${MOODS_DIR}/moods.conf" if [ -d "$MOODS_DIR" ]; then create_moods(){ mood_url=`echo "${MOODS_URL//\//\\\\/}\\\\/${mood_img//\//\\\\/}"` sed_sub=' '$mood_var'' sed_script='/[ ]'$mood_var'[ ]/ s// '$sed_sub' /g; /[ ]'$mood_var'$/ s// '$sed_sub'/g; /^'$mood_var'[ ]/ s//'$sed_sub' /g' NB_MetaBody=`echo "$NB_MetaBody" |sed -e "$sed_script"` } load_moods(){ if [ -f "$MOODS_CONF" ]; then if [ -z "$mood_lines" ]; then mood_lines=(`cat "$MOODS_CONF" |sed -e '/^$/d; /[\#\]/d; /[^ ].*/ s//dummy/g'`) fi if [ -z "$mood_list" ]; then mood_list=(`cat "$MOODS_CONF" |sed -e '/^$/d; /^[\#\]/d'`) fi moodoffset=0; moodlimit=3 for mood in ${mood_lines[@]}; do [ -z "${mood_list[*]:$moodoffset:$moodlimit}" ] && break mood_var=`echo "${mood_list[@]:$moodoffset:$moodlimit}" |cut -d" " -f1 | sed -e '/[\*\]/ s//[*]/'` mood_img=`echo "${mood_list[@]:$moodoffset:$moodlimit}" |cut -d" " -f3` create_moods let moodoffset=${moodoffset}+$moodlimit done fi } load_moods fi nanoblogger-3.4.2/plugins/post/clean_parts.off000644 000765 000024 00000000224 10552262306 022117 0ustar00kevinwstaff000000 000000 # plugin to cleanup parts directory if [ -d "$BLOG_DIR/$PARTS_DIR" ]; then nb_msg "cleaning up $PARTS_DIR ..." rm -fr "$BLOG_DIR/$PARTS_DIR"/* fi nanoblogger-3.4.2/plugins/page/feed_links.sh000644 000765 000024 00000003573 11336136365 021536 0ustar00kevinwstaff000000 000000 # NanoBlogger Page Plugin: Feed links # update category info if [ ! -z "$cat_arch" ] && [ "$cat_arch" != "$fdlinksprev_cat_arch" ]; then set_catlink "$cat_arch" fi fdlinksprev_cat_arch="$cat_arch" # Atom 1.0 if [ ! -z "$NB_AtomVer" ]; then NB_AtomLink="${BASE_URL}atom.$NB_SYND_FILETYPE" NB_AtomTitle="Atom $NB_AtomVer" if [ "$MKPAGE_TEMPLATE" = "$NB_TEMPLATE_DIR/$CATEGORY_TEMPLATE" ] && [[ "$CATEGORY_FEEDS" = 1 && "$ATOM_CATFEEDS" = 1 ]]; then NB_AtomCatFile="${category_file//[\.]$NB_FILETYPE/-atom.$NB_SYND_FILETYPE}" NB_AtomLink="${ARCHIVES_PATH}$NB_AtomCatFile" NB_AtomTitle="Atom $NB_AtomVer: $NB_ArchiveTitle" fi NB_AtomAltLink=$( cat <<-EOF EOF ) fi # RSS 2.0 if [ ! -z "$NB_RSS2Ver" ]; then NB_RSS2Link="${BASE_URL}rss.$NB_SYND_FILETYPE" NB_RSS2Title="RSS $NB_RSS2Ver" if [ "$MKPAGE_TEMPLATE" = "$NB_TEMPLATE_DIR/$CATEGORY_TEMPLATE" ] && [[ "$CATEGORY_FEEDS" = 1 && "$RSS2_CATFEEDS" = 1 ]]; then NB_RSS2CatFile="${category_file//[\.]$NB_FILETYPE/-rss.$NB_SYND_FILETYPE}" NB_RSS2Link="${ARCHIVES_PATH}$NB_RSS2CatFile" NB_RSS2Title="RSS $NB_RSS2Ver: $NB_ArchiveTitle" fi NB_RSS2AltLink=$( cat <<-EOF EOF ) fi # RSS 1.0 if [ ! -z "$NB_RSSVer" ]; then NB_RSSLink="${BASE_URL}index.$NB_SYND_FILETYPE" NB_RSSTitle="RSS $NB_RSSVer" if [ "$MKPAGE_TEMPLATE" = "$NB_TEMPLATE_DIR/$CATEGORY_TEMPLATE" ] && [[ "$CATEGORY_FEEDS" = 1 && "$RSS_CATFEEDS" = 1 ]]; then NB_RSSCatFile=`chg_suffix "$category_file" $NB_SYND_FILETYPE` NB_RSSLink="${ARCHIVES_PATH}$NB_RSSCatFile" NB_RSSTitle="RSS $NB_RSSVer: $NB_ArchiveTitle" fi NB_RSSAltLink=$( cat <<-EOF EOF ) fi nanoblogger-3.4.2/plugins/page/format/000755 000765 000024 00000000000 11336333423 020351 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/page/mod/000755 000765 000024 00000000000 11336333422 017637 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/page/format/autobr.sh000644 000765 000024 00000000370 10743565101 022202 0ustar00kevinwstaff000000 000000 # NanoBlogger Auto br plugin to convert line breaks to HTML # 2 line breaks (blank line) =

nb_msg "$plugins_entryfilteraction `basename $nb_plugin` ..." MKPAGE_CONTENT=`echo "$MKPAGE_CONTENT" |sed -e '/^$/ s//\
\
/g'` nanoblogger-3.4.2/plugins/page/format/markdown.sh000644 000765 000024 00000000744 11237661541 022541 0ustar00kevinwstaff000000 000000 # NanoBlogger plugin to filter page content through markdown # Markdown is documented and implemented at # : ${MARKDOWN_CMD:=markdown} : ${MARKDOWN_OPTS:= } nb_eval "$MARKDOWN_CMD" && MARKDOWN_INPATH=true if [ "$MARKDOWN_INPATH" = "true" ]; then nb_msg "$plugins_entryfilteraction `basename $nb_plugin` ..." MKPAGE_CONTENT=`echo "$MKPAGE_CONTENT" | ${MARKDOWN_CMD} ${MARKDOWN_OPTS}` else die "$nb_plugin: $plugins_abort" fi nanoblogger-3.4.2/plugins/page/format/moods.sh000644 000765 000024 00000002403 10743565101 022026 0ustar00kevinwstaff000000 000000 # Page Formatting plugin that converts mood variables # to emoticons - controlled by moods.conf file : ${MOODS_DIR:=$BLOG_DIR/moods} MOODS_URL="${BASE_URL}moods" MOODS_CONF="${MOODS_DIR}/moods.conf" if [ -d "$MOODS_DIR" ]; then create_moods(){ mood_url=`echo "${MOODS_URL//\//\\\\/}\\\\/${mood_img//\//\\\\/}"` sed_sub=' '$mood_var'' sed_script='/[ ]'$mood_var'[ ]/ s// '$sed_sub' /g; /[ ]'$mood_var'$/ s// '$sed_sub'/g; /'$mood_var'[ ]/ s//'$sed_sub' /g' MKPAGE_CONTENT=`echo "$MKPAGE_CONTENT" |sed -e "$sed_script"` } load_moods(){ if [ -f "$MOODS_CONF" ]; then if [ -z "$mood_lines" ]; then mood_lines=(`cat "$MOODS_CONF" |sed -e '/^$/d; /[\#\]/d; /[^ ].*/ s//dummy/g'`) fi if [ -z "$mood_list" ]; then mood_list=(`cat "$MOODS_CONF" |sed -e '/^$/d; /^[\#\]/d'`) fi moodoffset=0; moodlimit=3 for mood in ${mood_lines[@]}; do [ -z "${mood_list[*]:$moodoffset:$moodlimit}" ] && break mood_var=`echo "${mood_list[@]:$moodoffset:$moodlimit}" |cut -d" " -f1 | sed -e '/[\*\]/ s//[*]/'` mood_img=`echo "${mood_list[@]:$moodoffset:$moodlimit}" |cut -d" " -f3` create_moods let moodoffset=${moodoffset}+$moodlimit done fi } nb_msg "$plugins_entryfilteraction `basename $nb_plugin` ..." load_moods fi nanoblogger-3.4.2/plugins/page/format/raw.sh000644 000765 000024 00000000123 10321570721 021467 0ustar00kevinwstaff000000 000000 # NanoBlogger plugin to filter raw page content MKPAGE_CONTENT="$MKPAGE_CONTENT" nanoblogger-3.4.2/plugins/makepage/tidy.sh000644 000765 000024 00000003571 11237661541 021237 0ustar00kevinwstaff000000 000000 # NanoBlogger tidy plugin, requires program, tidy. # # Tidy is an HTML syntax checker and reformatter. # See the man pages for more information. # sample code for templates, based off default stylesheet # #
# Validation #
# #
# $NB_Tidy #
# set tidy command : ${TIDY_CMD:=tidy} # set additional arguments : ${TIDY_HTML_ARGS:=-asxhtml -n -utf8} : ${TIDY_XML_ARGS:=-xml -n -utf8 -wrap 0} # file to log tidy errors to TIDY_LOGFILE="$BLOG_DIR/tidy.log" TIDY_PLUGIN_OUTFILE="$BLOG_DIR/$PARTS_DIR/tidy.$NB_FILETYPE" # display tidy information tidy_info(){ exitcode="$?" if [ "$exitcode" = 1 ]; then nb_msg "tidy issued warning messages" elif [ "$exitcode" = 2 ]; then nb_msg "tidy issued error messages" elif [ "$exitcode" != 0 ]; then nb_msg "tidy exited with code: $exitcode" fi [ ! -N "$MKPAGE_OUTFILE" ] && die "tidy FAILED to modify input" } if nb_eval "$TIDY_CMD -v"; then if [ ! -f "$TIDY_LOGFILE" ] || [ "$tidylog_restarted" != 1 ]; then > "$TIDY_LOGFILE" tidylog_restarted=1 fi # detect file's suffix TIDY_SUFFIX_VAR="${MKPAGE_OUTFILE##*.}" if [ "$TIDY_SUFFIX_VAR" = "$NB_FILETYPE" ]; then nb_msg "tidy validating $MKPAGE_OUTFILE ..." cat >> "$TIDY_LOGFILE" <<-EOF tidy validating $MKPAGE_OUTFILE: EOF $TIDY_CMD $TIDY_HTML_ARGS -m $MKPAGE_OUTFILE >> "$TIDY_LOGFILE" 2>&1 tidy_info fi if [ "$TIDY_SUFFIX_VAR" = "$NB_SYND_FILETYPE" ]; then nb_msg "tidy validating $MKPAGE_OUTFILE ..." cat >> "$TIDY_LOGFILE" <<-EOF tidy validating $MKPAGE_OUTFILE: EOF $TIDY_CMD $TIDY_XML_ARGS -m "$MKPAGE_OUTFILE" >> "$TIDY_LOGFILE" 2>&1 tidy_info fi echo ' "$TIDY_PLUGIN_OUTFILE" echo 'src="http://www.w3.org/Icons/valid-xhtml11"' >> "$TIDY_PLUGIN_OUTFILE" echo 'alt="Valid XHTML!" />' >> "$TIDY_PLUGIN_OUTFILE" NB_Tidy=$(< "$TIDY_PLUGIN_OUTFILE") fi nanoblogger-3.4.2/plugins/entry/category_links.sh000644 000765 000024 00000001564 10742555266 022700 0ustar00kevinwstaff000000 000000 # NanoBlogger Category Links Plugin # Entry Plugin to find related categories and generate links for them if [ "$SHOW_CATLINKS" = 1 ]; then # Command to help filter order of categories : ${CATLINKS_FILTERCMD:=sort} >"$SCRATCH_FILE".cat_links entry_wcatids=`grep "$entry" "$NB_DATA_DIR/master.$NB_DBTYPE"` entry_catids="${entry_wcatids##*\>}" [ "$entry_wcatids" = "$entry_catids" ] && entry_catids= for entry_catnum in ${entry_catids//\,/ }; do cat_title=`nb_print "$NB_DATA_DIR"/cat_"$entry_catnum.$NB_DBTYPE" 1` set_catlink cat_"$entry_catnum.$NB_DBTYPE" cat_index="$category_link" # following must fit on single line $CATLINKS_FILTERCMD >> "$SCRATCH_FILE".cat_links <<-EOF $cat_title, EOF done NB_EntryCategories=$(< "$SCRATCH_FILE.cat_links") NB_EntryCategories="${NB_EntryCategories%%,}" fi nanoblogger-3.4.2/plugins/entry/format/000755 000765 000024 00000000000 11336333422 020575 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/entry/mod/000755 000765 000024 00000000000 11336333422 020064 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/entry/format/autotag-br.sh000644 000765 000024 00000000374 11336117757 023215 0ustar00kevinwstaff000000 000000 # NanoBlogger Auto
tag plugin that converts line breaks to HTML # 2 line breaks (blank line) =

# nb_msg "$plugins_entryfilteraction `basename $nb_plugin` ..." NB_MetaBody=`echo "$NB_MetaBody" |sed -e '/^$/ s//\
\
/g'` nanoblogger-3.4.2/plugins/entry/format/markdown.sh000644 000765 000024 00000000734 11336060051 022752 0ustar00kevinwstaff000000 000000 # NanoBlogger plugin to render Markdown format entries # Markdown is documented and implemented at # : ${MARKDOWN_CMD:=markdown} : ${MARKDOWN_OPTS:= } nb_eval "$MARKDOWN_CMD" && MARKDOWN_INPATH=true if [ "$MARKDOWN_INPATH" = "true" ]; then # nb_msg "$plugins_entryfilteraction `basename $nb_plugin` ..." NB_MetaBody=$(echo "$NB_MetaBody" | ${MARKDOWN_CMD} ${MARKDOWN_OPTS}) else die "$nb_plugin: $plugins_abort" fi nanoblogger-3.4.2/plugins/entry/format/raw.sh000644 000765 000024 00000000175 11336060051 021720 0ustar00kevinwstaff000000 000000 # NanoBlogger dummy plugin for raw output # For "raw" processing, don't process the body at all NB_MetaBody="$NB_MetaBody" nanoblogger-3.4.2/plugins/archive/category/000755 000765 000024 00000000000 11336333422 021402 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/archive/day/000755 000765 000024 00000000000 11336333422 020342 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/archive/master_index.sh000644 000765 000024 00000007252 11336117757 022624 0ustar00kevinwstaff000000 000000 # NanoBlogger Plugin that creates a master archive index # in conjunction with the yearly archive indexes created # by archive/year/year_index.sh plugin # command used to filter order of category links : ${CATLINKS_FILTERCMD:=sort} # concatenate modification variables MASTERIMOD_VAR="$New_EntryFile$Edit_EntryFile$Delete_EntryFile$Delete_CatDBFile$Cat_EntryFile$USR_TITLE" MASTERIMOD_QUERY=`echo "$NB_QUERY" |grep "^[0-9].*"` # check for weblog modifications if [ ! -z "$MASTERIMOD_VAR" ] || [ ! -z "$MASTERIMOD_QUERY" ] || [ "$NB_QUERY" = all ]; then nb_msg "$plugins_action archive index page ..." # help ease transition from 3.2.x or earlier YEAR_TEMPLATECOPY="$NB_BASE_DIR/default/templates/$YEAR_TEMPLATE" if [ ! -f "$NB_TEMPLATE_DIR/$YEAR_TEMPLATE" ] ; then # YEAR_TEMPLATE doesn't exist, get it from default cp "$YEAR_TEMPLATECOPY" "$NB_TEMPLATE_DIR/$YEAR_TEMPLATE" || die "$nb_plugin: failed to copy '$YEAR_TEMPLATECOPY!' repair nanoblogger! goodbye." fi # make NB_ArchiveEntryLinks placeholder query_db set_baseurl "../" # create links for categories build_catlinks(){ for bcat_link in ${db_categories[*]}; do if [ -f "$NB_DATA_DIR/$bcat_link" ]; then set_catlink "$bcat_link" cat_index="$category_link" query_db "$db_query" "$bcat_link" cat_total=${#DB_RESULTS[*]} NB_ArchiveCategoryTitle=`nb_print "$NB_DATA_DIR/$bcat_link" 1` # following needs to fit on single line cat <<-EOF $NB_ArchiveCategoryTitle ($cat_total)
EOF fi done } build_catlinks |$CATLINKS_FILTERCMD |sed -e 's///' > "$SCRATCH_FILE.cat_links.$NB_FILETYPE" NB_ArchiveCategoryLinks=$(< "$SCRATCH_FILE.cat_links.$NB_FILETYPE") make_yearlink(){ NB_ArchiveYearTitle="$yearlink" query_db "$yearlink" year_total=${#DB_RESULTS[*]} # following needs to fit on single line cat <<-EOF $NB_ArchiveYearTitle ($year_total)
EOF } query_db all YEARLINKS_LIST=(`for yearlink in ${DB_RESULTS[*]}; do echo $yearlink done |cut -c1-4 |sort $SORT_ARGS`) for yearlink in ${YEARLINKS_LIST[*]}; do make_yearlink done |sort $SORT_ARGS > "$SCRATCH_FILE.year_links.$NB_FILETYPE" NB_ArchiveYearLinks=$(< "$SCRATCH_FILE.year_links.$NB_FILETYPE") cat_total=${#db_categories[*]} if [ "$cat_total" -gt 0 ]; then # make NB_CategoryLinks placeholder NB_BrowseCategoryLinks=$( cat <<-EOF $template_browsecat
$NB_ArchiveCategoryLinks

EOF ) fi # make NB_ArchiveLinks placeholder cat > "$BLOG_DIR"/"$PARTS_DIR"/archive_links.$NB_FILETYPE <<-EOF $NB_BrowseCategoryLinks $template_browsedate
$NB_ArchiveYearLinks
EOF NB_ArchiveLinks=$(< "$BLOG_DIR/$PARTS_DIR/archive_links.$NB_FILETYPE") # build master archive index MKPAGE_OUTFILE="$BLOG_DIR/$ARCHIVES_DIR/$NB_INDEXFILE" # set title for makepage template MKPAGE_TITLE="$template_archives" MKPAGE_CONTENT="$NB_ArchiveLinks" ARCHIVE_INDEX_TEMPLATECOPY="$NB_BASE_DIR/default/templates/archive_index.htm" ARCHIVE_INDEX_TEMPLATE="$NB_TEMPLATE_DIR/archive_index.htm" if [ ! -f "$ARCHIVE_INDEX_TEMPLATE" ] ; then # ARCHIVE_INDEX_TEMPLATE does not exist, get it from default cp "$ARCHIVE_INDEX_TEMPLATECOPY" "$ARCHIVE_INDEX_TEMPLATE" || die "$nb_plugin: failed to copy '$ARCHIVE_INDEX_TEMPLATE'! please repair nanoblogger! goodbye/" fi [ -r "$ARCHIVE_INDEX_TEMPLATE" ] || die "`basename $0`: '$ARCHIVE_INDEX_TEMPLATE' - missing template! goodbye." make_page "$BLOG_DIR/$PARTS_DIR"/archive_links.$NB_FILETYPE "$NB_TEMPLATE_DIR/$MAKEPAGE_TEMPLATE" "$MKPAGE_OUTFILE" fi nanoblogger-3.4.2/plugins/archive/month/000755 000765 000024 00000000000 11336333422 020712 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/archive/year/000755 000765 000024 00000000000 11336333422 020525 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/plugins/archive/year/year_archive.sh000644 000765 000024 00000012633 11237661541 023535 0ustar00kevinwstaff000000 000000 # NanoBlogger Plugin that creates yearly archive indexes # concatenate modification variables YEARIMOD_VAR="$New_EntryFile$Edit_EntryFile$Delete_EntryFile$Cat_EntryFile$USR_TITLE" build_yeararchive(){ query_db "$yearn" YEARIMOD_QUERY=`echo "$NB_QUERY" |grep "^$yearn"` # check for weblog modifications if [ ! -z "$YEARIMOD_VAR" ] || [ ! -z "$YEARIMOD_QUERY" ] || [ "$NB_QUERY" = all ] || [ ! -z "$UPDATE_LIST" ]; then # set previous and next links for given year set_yearnavlinks(){ yearnavlinks_var=${1//[\/]/-} year_id= [ ! -z "$yearnavlinks_var" ] && year_id=`lookup_id "$yearnavlinks_var" "${YEAR_DB_RESULTS[*]}"` if [ ! -z "$year_id" ] && [ $year_id -ge 0 ]; then # adjust for bash array - 1 = 0 ((year_id--)) # determine direction based on chronological date order if [ "$CHRON_ORDER" = 1 ]; then let prev_yearid=${year_id}+1 let next_yearid=${year_id}-1 else let prev_yearid=${year_id}-1 let next_yearid=${year_id}+1 fi prev_year=; NB_PrevArchiveYearLink= [ $prev_yearid -ge 0 ] && prev_year=${YEAR_DB_RESULTS[$prev_yearid]} if [ ! -z "$prev_year" ]; then prev_year_dir=${prev_year//[-]//} prev_year_file="$prev_year_dir/$NB_INDEXFILE" NB_PrevArchiveYearLink="$prev_year_dir/$NB_INDEX" fi next_year=; NB_NextArchiveYearLink= [ $next_yearid -ge 0 ] && next_year=${YEAR_DB_RESULTS[$next_yearid]} if [ ! -z "$next_year" ]; then next_year_dir=${next_year//[-]//} next_year_file="$next_year_dir/$NB_INDEXFILE" NB_NextArchiveYearLink="$next_year_dir/$NB_INDEX" fi fi } [ "$pluginyearindex_msg" != 1 ] && nb_msg "$plugins_action year archives ..." && pluginyearindex_msg=1 # make NB_ArchiveEntryLinks placeholder set_baseurl "../../" ARCHENTRY_LIST=${DB_RESULTS[*]} NB_ArchiveEntryLinks=$( for entry in ${ARCHENTRY_LIST[*]}; do NB_EntryID=$x_id${entrylink_var//[\/]/-} set_entrylink "$entry" # 1st try to get title from set_entrylink instance of read_metadata NB_ArchiveEntryTitle="$smartlink_metatitle" if [ -z "$NB_ArchiveEntryTitle" ]; then read_metadata TITLE "$NB_DATA_DIR/$entry" NB_ArchiveEntryTitle="$METADATA" fi [ -z "$NB_ArchiveEntryTitle" ] && NB_ArchiveEntryTitle="$notitle" set_monthlink "$month" if [ "$SHOW_CATLINKS" = 1 ];then # Command to help filter order of categories : ${CATLINKS_FILTERCMD:=sort} >"$SCRATCH_FILE".cat_links entry_wcatids=`grep "$entry" "$NB_DATA_DIR/master.$NB_DBTYPE"` entry_catids=${entry_wcatids##*\>} [ "$entry_wcatids" = "$entry_catids" ] && entry_catids= for entry_catnum in ${entry_catids//\,/ }; do cat_title=`nb_print "$NB_DATA_DIR"/cat_"$entry_catnum.$NB_DBTYPE" 1` set_catlink cat_"$entry_catnum.$NB_DBTYPE" cat_index="$category_link" # following must fit on single line $CATLINKS_FILTERCMD >> "$SCRATCH_FILE".cat_links <<-EOF $cat_title, EOF done NB_EntryCategories=$(< "$SCRATCH_FILE.cat_links") NB_EntryCategories="${NB_EntryCategories%%,}" fi if [ "$MONTH_ARCHIVES" = 1 ]; then yearindex_monthlink=''$month'' else yearindex_monthlink="$month" fi cat <<-EOF $yearindex_monthlink - $NB_ArchiveEntryTitle $([ ! -z "$NB_EntryCategories" ] && echo "- $NB_EntryCategories")
EOF done; month= ) # create links for monthly archives [ -z "$CAL_CMD" ] && CAL_CMD="cal" nb_eval "$CAL_CMD" && CAL_VAR="1" make_monthlink(){ if [ "$CAL_VAR" = "1" ]; then [ ! -z "$DATE_LOCALE" ] && CALENDAR=`LC_ALL="$DATE_LOCALE" $CAL_CMD $CAL_ARGS $monthn $yearn` [ -z "$DATE_LOCALE" ] && CALENDAR=`$CAL_CMD $CAL_ARGS $monthn $yearn` CAL_HEAD=`echo "$CALENDAR" |sed 1q` CAL_HEAD=${CAL_HEAD//[ ][ ]/}; NB_ArchiveMonthTitle=${CAL_HEAD%%[ ][ ]}; NB_ArchiveMonthTitle=${CAL_HEAD##[ ][ ]} else NB_ArchiveMonthTitle="$month" fi month_total=${#DB_RESULTS[*]} set_monthlink "$month" # following needs to fit on single line cat <<-EOF $NB_ArchiveMonthTitle ($month_total)
EOF } [ -z "${YEAR_DB_RESULTS[*]}" ] && query_db years set_yearnavlinks "$yearn" if [ "$MONTH_ARCHIVES" = 1 ]; then loop_archive "${DB_RESULTS[*]}" months make_monthlink |sort $SORT_ARGS \ > "$SCRATCH_FILE.$yearn-month_links.$NB_FILETYPE" NB_ArchiveMonthLinks=$(< "$SCRATCH_FILE.$yearn-month_links.$NB_FILETYPE") yearindex_monthbrowse=''$template_browsedate'' fi # make NB_ArchiveLinks placeholder mkdir -p `dirname "$BLOG_DIR/$PARTS_DIR/$yearn/archive_links.$NB_FILETYPE"` cat > "$BLOG_DIR"/"$PARTS_DIR"/"$yearn"/archive_links.$NB_FILETYPE <<-EOF $yearindex_monthbrowse
$NB_ArchiveMonthLinks

$template_browseentry
$NB_ArchiveEntryLinks
EOF NB_ArchiveLinks=$(< "$BLOG_DIR/$PARTS_DIR/$yearn/archive_links.$NB_FILETYPE") # build master archive index MKPAGE_OUTFILE="$BLOG_DIR/$ARCHIVES_DIR/$yearn/$NB_INDEXFILE" # set title for makepage template MKPAGE_TITLE="$yearn $template_archives" MKPAGE_CONTENT="$NB_ArchiveLinks" make_page "$BLOG_DIR/$PARTS_DIR/$yearn/archive_links.$NB_FILETYPE" "$NB_TEMPLATE_DIR/$YEAR_TEMPLATE" "$MKPAGE_OUTFILE" fi } loop_archive "${LOOP_LIST[*]}" years build_yeararchive nanoblogger-3.4.2/plugins/archive/month/month_archive.sh000644 000765 000024 00000002553 10743565101 024103 0ustar00kevinwstaff000000 000000 # build monthly archives build_montharchive(){ export CACHE_TYPE=month [ ! -z "$MONTHARCH_DATATYPE" ] && ARCH_DATATYPE="$MONTHARCH_DATATYPE" query_db "$month" if [ ! -z "${DB_RESULTS[*]}" ]; then LOOPMONTH_LIST=(${DB_RESULTS[*]}) [ "$NB_QUERY" != all ] && LOOPMONTH_LIST=(`for update_entry in ${UPDATE_LIST[@]}; do \ for month_entry in ${DB_RESULTS[@]}; do echo $month_entry; done \ |grep "$update_entry"; done`) set_monthlink "$month" set_monthnavlinks "$month" set_baseurl "" "$BLOG_DIR/$ARCHIVES_DIR/$month_file" make_archive "$month" nocat "$MONTHENTRY_TEMPLATE" "$BLOG_DIR/$PARTS_DIR/$month_file" NB_ArchiveTitle="$month" # check if make_calendar() is provided by calendar.sh plugin if [ ! -z $PLUGIN_CALENDAR ] && [ ! -z "$CAL_HEAD" ]; then make_calendar "${month:0:4}" "${month:5:6}" "$BLOG_DIR/$PARTS_DIR/$month_dir/cal.$NB_FILETYPE" # month calendar's place-holder for the templates NB_MonthlyCalendar=$(< "$BLOG_DIR/$PARTS_DIR/$month_dir/cal.$NB_FILETYPE") # pretty-print NB_ArchiveTitle NB_ArchiveTitle="$CAL_HEAD" fi paginate "$month" nocat "$MAX_MONTHPAGE_ENTRIES" "$MONTH_TEMPLATE" \ "$MONTHENTRY_TEMPLATE" "$BLOG_DIR/$ARCHIVES_DIR/" "$month_file" if [ "$DAY_ARCHIVES" = 1 ]; then # plugins for archiving by day load_plugins archive/day fi fi } loop_archive "${LOOP_LIST[*]}" months build_montharchive nanoblogger-3.4.2/plugins/archive/day/day_archive.sh000644 000765 000024 00000002253 10743565101 023160 0ustar00kevinwstaff000000 000000 # build daily archives build_dayarchive(){ export CACHE_TYPE=day [ ! -z "$DAYARCH_DATATYPE" ] && ARCH_DATATYPE="$DAYARCH_DATATYPE" query_db "$day" if [ ! -z "${DB_RESULTS[*]}" ]; then set_daylink "$day" set_daynavlinks "$day" set_baseurl "" "$BLOG_DIR/$ARCHIVES_DIR/$day_file" make_archive "$day" nocat "$DAYENTRY_TEMPLATE" "$BLOG_DIR/$PARTS_DIR/$day_file" NB_ArchiveTitle="$day_dir" dayn=${day:8:2} # pretty-print daily archive title, replaces $NB_ArchiveTitle if [ ! -z $PLUGIN_CALENDAR ] && [ ! -z "$CAL_HEAD" ]; then DayMonthTitle=${CAL_HEAD//$yearn/} DayMonthTitle=${DayMonthTitle// } NB_ArchiveTitle="$DayMonthTitle $dayn, $yearn" fi make_page "$BLOG_DIR/$PARTS_DIR/$day_file" "$NB_TEMPLATE_DIR/$DAY_TEMPLATE" \ "$BLOG_DIR/$ARCHIVES_DIR/$day_file" fi } loop_day(){ loopday_list=($1) loopday_exec="$2" LOOP_MASTER=(${loopday_list[*]}) ARCHIVE_DAYS=(`for db_item in ${LOOP_MASTER[@]}; do echo $db_item; done |cut -c1-10 |sort $SORT_ARGS`) for dayn in ${ARCHIVE_DAYS[@]}; do day="$dayn" query_db "$day" [ ! -z "${DB_RESULTS[*]}" ] && [ ! -z "$loopday_exec" ] && $loopday_exec done } loop_day "${LOOPMONTH_LIST[*]}" build_dayarchive nanoblogger-3.4.2/moods/moods.conf000644 000765 000024 00000001037 10321651266 017577 0ustar00kevinwstaff000000 000000 # Configuration file for NanoBlogger's autoformat, moods.sh plugin # mood = image filename :) = smilies/smiley.gif :( = smilies/sad.gif ;) = smilies/wink.gif :D = smilies/grin.gif :cry: = smilies/cry.gif :laugh: = smilies/laugh.gif :P = smilies/tongue.gif :* = smilies/kiss.gif 8) = smilies/cool.gif :huh: = smilies/huh.gif :O = smilies/shocked.gif :roll: = smilies/rolleyes.gif :embarassed: = smilies/embarassed.gif :angry: = smilies/angry.gif :cheesey: = smilies/cheesy.gif :sealed: = smilies/lipsrsealed.gif :X = smilies/lipsrsealed.gif nanoblogger-3.4.2/moods/mymood.txt000644 000765 000024 00000000003 10021535235 017636 0ustar00kevinwstaff000000 000000 :) nanoblogger-3.4.2/moods/smilies/000755 000765 000024 00000000000 11336333422 017251 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/moods/smilies/angry.gif000644 000765 000024 00000001720 10021535235 021054 0ustar00kevinwstaff000000 000000 GIF89a2,61;5?;ZQj_~pvJįŰʴѻAci𠠤!>,}`}pPBEH Rh@D/f $DP.<@b `Ѣ& `Q QCSH}tD8l(x"rА!Cӥ$ |C `JA0, Xб.\Qa]b L.(L e;nanoblogger-3.4.2/moods/smilies/cheesy.gif000644 000765 000024 00000001706 10021535235 021220 0ustar00kevinwstaff000000 000000 GIF89a2,61;5?;~pryįŰʴкֿAci𠠤!?,`pPb HF,Qa"A4fȈ<:1CƋC@a. @a``;pPPӇ'FA(P@B2dHj0H`/\X@L,|TA6f !@x#2ZeA׸@> z0W 4-۾"$ Ē-`` V"2 ;nanoblogger-3.4.2/moods/smilies/kiss.gif000644 000765 000024 00000001056 10021535235 020707 0ustar00kevinwstaff000000 000000 GIF89a/1)119199{sJZ{JRZƌƭƵƽενֽBck! NETSCAPE2.0!</,P(*D P'9.V*+}</ab[OG#PPb\TE&&'E$[E$""gEf~[  i/  D ~^J D HFGHA!/,+pH,Ȥrl:!ȃL"ر/ qܼ&DA!(/,"pH,Ȥrl:ТcYv&HZ&# ! /,!pH,Ȥrl:"2YZ /HNPF4;nanoblogger-3.4.2/moods/smilies/laugh.gif000644 000765 000024 00000001137 10021535235 021036 0ustar00kevinwstaff000000 000000 GIF89a01)119199BRJZZRkZkcsc{sƭƵƽενֽ119Bck! NETSCAPE2.0!0,{@P(H@ ЬP5Y8UK7JN#X E%FE"/nE Fg0ED$$ ^JDHIA! 0,5@pH,$* =%LQëd*Dcnr)|1!0,A@pH,Ȥ2Rr ! 1,1pH,ȤY!y1J -FIeL0 &"V/|NW!H1,,pH,ȤsbU^[bazn ! 1,1pH,ȤY!y1J -FIeL0 &"V/|NW;nanoblogger-3.4.2/moods/smilies/sad.gif000644 000765 000024 00000001706 10021535235 020507 0ustar00kevinwstaff000000 000000 GIF89a2,61;5?;ZQj_~pvįŰʴѻAci𠠤!?,`p`b  HF,(Qa"A4fȈD<:1CƋI@. @qt`Q0Ƃ >|($BCAX7BYUZ!|! @0, XAԪf/Dmhp;nanoblogger-3.4.2/moods/smilies/shocked.gif000644 000765 000024 00000002347 10021535235 021362 0ustar00kevinwstaff000000 000000 GIF89a6))))1)119199JBRJcZBkZsc{k{ss{{ckƭƵƽενֽBck! NETSCAPE2.0!6,@P(H`RN \g4;+{*F!6gч4^EUP,,-E)[E)''gEf#}[%#ri6f""FD# F ^J}F DHFGHA! 6,2@pH,Ȥ663b+ܰqVJ'vYb|NۇA! 6,B@pH,llj!Zcbf b-4ȑ Q/~F FA! 6,L@pH,E ]bPTa( /` g@%Z3X.Q,'KG#EHHCQA! 6,X@pH,NŲJIlR$24pBlD B9LPu2d@% OYz"UEP#" G"EG HC A! 6,L@pH,E ]bPTa( /` g@%Z3X.Q,'KG#EHHCQA! 6,X@pH,NŲJIlR$24pBlD B9LPu2d@% OYz"UEP#" G"EG HC A! 6,L@pH,E ]bPTa( /` g@%Z3X.Q,'KG#EHHCQA! 6,X@pH,NŲJIlR$24pBlD B9LPu2d@% OYz"UEP#" G"EG HC A! 6,J@pH,6{liTuMʂ|.p۲DPZg R`! ~6yH$6JFF FA;nanoblogger-3.4.2/moods/smilies/smiley.gif000644 000765 000024 00000001711 10021535235 021236 0ustar00kevinwstaff000000 000000 GIF89a2,61;5?;WNeZ~pyįŰʴθѻAci𠠤!?,`p`b HF,(Qa"A4fȈD<:1CƋI@. @q t`Q0Ƃt Ka HZU &Ll`r2``?ʽB Q=p /Ek/E;nanoblogger-3.4.2/moods/smilies/tongue.gif000644 000765 000024 00000001706 10021535235 021241 0ustar00kevinwstaff000000 000000 GIF89a2,61;5?;~prxįŰʴкֿAci𠠤!?,`p`b HF, Qa"A4fȈ<:1CƋE@. (Y :Y(bcA:TT# >9pP%FՐ! a$N A  '[xTHgB &,KQl€;nanoblogger-3.4.2/moods/smilies/wink.gif000644 000765 000024 00000001713 10021535235 020706 0ustar00kevinwstaff000000 000000 GIF89a2,61;5?;WNeZ~pyįŰʴθѻ;Aci𠠤!?,`pPBEHF+ Qa"A4fx <:1CƋG@a.^PqD,Tb=tP0S'AxaCX7! " B2Lda 2z{!GvؠXa‚ B;nanoblogger-3.4.2/lib/archive.sh000644 000765 000024 00000041466 11063754470 017230 0ustar00kevinwstaff000000 000000 # Module for archive functions # Last modified: 2008-07-16T22:54:53-04:00 # set base url based on parameters set_baseurl(){ node_var="$1" base_dir=`dirname "$2"` # check if we want absolute links if [ "$ABSOLUTE_LINKS" = 1 ]; then BASE_URL="$BLOG_URL/" else BASE_URL="$node_var" if [ "$base_dir" != . ]; then blogdir_sedvar=`echo "${BLOG_DIR//\//\\\\/}\\\\/"` base_dir="$base_dir/./" BASE_URL=`echo "$base_dir" |sed -e 's/'$blogdir_sedvar'//g; /^[\.]\// s///; s/[^ \/]*./..\//g; s/^[\.][\.]\///g'` fi [ -z "$BASE_URL" ] && BASE_URL="./" fi # set link path to archives ARCHIVES_PATH="${BASE_URL}$ARCHIVES_DIR/" } # set link/file for given category set_catlink(){ catlink_var="$1" # title-based links category_title=`nb_print "$NB_DATA_DIR/$catlink_var" 1` category_dir=`set_smartlinktitle "$catlink_var" cat` # failsafe for setting cat directories : ${category_dir:=${catlink_var%%\.*}} category_file="$category_dir/$NB_INDEXFILE" category_link="$category_dir/$NB_INDEX" } # set link/file for given month set_monthlink(){ month_dir="${1//\-//}" month_file="$month_dir/$NB_INDEXFILE" NB_ArchiveMonthLink="$month_dir/$NB_INDEX" } set_daylink(){ day_dir="${1//\-//}" day_file="$day_dir/$NB_INDEXFILE" NB_ArchiveDayLink="$day_dir/$NB_INDEX" } set_daynavlinks(){ daynavlinks_var="${1//\//-}" day_id= [ ! -z "$daynavlinks_var" ] && day_id=`lookup_id "$daynavlinks_var" "${DAY_DB_RESULTS[*]}"` if [ ! -z "$day_id" ] && [ $day_id -gt 0 ]; then # adjust for bash array - 1 = 0 ((day_id--)) # determine direction based on chronological date order if [ "$CHRON_ORDER" = 1 ]; then let prev_dayid=${day_id}+1 let next_dayid=${day_id}-1 else let prev_dayid=${day_id}-1 let next_dayid=${day_id}+1 fi prev_day=; NB_PrevArchiveDayLink= [ $prev_dayid -ge 0 ] && prev_day=${DAY_DB_RESULTS[$prev_dayid]} if [ ! -z "$prev_day" ]; then prev_day_dir="${prev_day//\-//}" prev_day_file="$prev_day_dir/$NB_INDEXFILE" NB_PrevArchiveDayLink="$prev_day_dir/$NB_INDEX" fi next_day=; NB_NextArchiveDayLink= [ $next_dayid -ge 0 ] && next_day=${DAY_DB_RESULTS[$next_dayid]} if [ ! -z "$next_day" ]; then next_day_dir="${next_day//\-//}" next_day_file="$next_day_dir/$NB_INDEXFILE" NB_NextArchiveDayLink="$next_day_dir/$NB_INDEX" fi fi } # set previous and next links for given month set_monthnavlinks(){ monthnavlinks_var="${1//\//-}" month_id= [ ! -z "$monthnavlinks_var" ] && month_id=`lookup_id "$monthnavlinks_var" "${MONTH_DB_RESULTS[*]}"` if [ ! -z "$month_id" ] && [ $month_id -gt 0 ]; then # adjust for bash array - 1 = 0 ((month_id--)) # determine direction based on chronological date order if [ "$CHRON_ORDER" = 1 ]; then let prev_monthid=${month_id}+1 let next_monthid=${month_id}-1 else let prev_monthid=${month_id}-1 let next_monthid=${month_id}+1 fi prev_month=; NB_PrevArchiveMonthLink= [ $prev_monthid -ge 0 ] && prev_month=${MONTH_DB_RESULTS[$prev_monthid]} if [ ! -z "$prev_month" ]; then prev_month_dir="${prev_month//\-//}" prev_month_file="$prev_month_dir/$NB_INDEXFILE" NB_PrevArchiveMonthLink="$prev_month_dir/$NB_INDEX" fi next_month=; NB_NextArchiveMonthLink= [ $next_monthid -ge 0 ] && next_month=${MONTH_DB_RESULTS[$next_monthid]} if [ ! -z "$next_month" ]; then next_month_dir="${next_month//\-//}" next_month_file="$next_month_dir/$NB_INDEXFILE" NB_NextArchiveMonthLink="$next_month_dir/$NB_INDEX" fi fi } # generate entry's anchor/id set_entryid(){ echo "$x_id${1//[\/]/-}" } # use instead of translit_text to avoid file/URL collissions set_smartlinktitle(){ altlink_var="$1" altlink_type="$2" case "$altlink_type" in entry) [ -f "$NB_DATA_DIR/$altlink_var" ] && read_metadata TITLE "$NB_DATA_DIR/$altlink_var" smartlink_metatitle="$METADATA" altentry_linktitle=`translit_text "$METADATA"` # search for similar titles that fall on same day alte_day=${altlink_var:0:10} query_db "$alte_day" ALTLINK_LIST=(${DB_RESULTS[*]}) if [ "${#ALTLINK_LIST}" -gt 1 ]; then for alte in ${ALTLINK_LIST[*]}; do [ -f "$NB_DATA_DIR/$alte" ] && read_metadata TITLE "$NB_DATA_DIR/$alte" alte_linktitle=`translit_text "$METADATA"` # entry title failsafe [ -z "$alte_linktitle" ] && alte_linktitle=`translit_text "$notitle"` echo "$alte:$alte_linktitle" done |sort $SORT_ARGS > "$SCRATCH_FILE".altlinks fi link_match="$altentry_linktitle" alte_backup=${altlink_var//-//}; alte_backup=${alte_backup//T//T} alte_backup=${alte_backup%%.*}; altlink_backup="${alte_backup//*\/}" ;; cat) [ -f "$NB_DATA_DIR/$altlink_var" ] && altcat_title=`nb_print "$NB_DATA_DIR/$altlink_var" 1` altcat_linktitle=`translit_text "$altcat_title"` query_db # get categories list ALTLINK_LIST=(${db_categories[*]}) for altt in ${ALTLINK_LIST[*]}; do [ -f "$NB_DATA_DIR/$altt" ] && altt_title=`nb_print "$NB_DATA_DIR/$altt" 1` altt_linktitle=`translit_text "$altt_title"` # cat title failsafe [ -z "$altt_linktitle" ] && altt_linktitle=`translit_text "$notitle"` echo "$altt:$altt_linktitle" done |sort $SORT_ARGS > "$SCRATCH_FILE".altlinks link_match="$altcat_linktitle" altlink_backup=${altlink_var%%\.*} ;; esac [ ! -f "$SCRATCH_FILE".altlinks ] && > "$SCRATCH_FILE".altlinks # link match failsafe [ -z "$link_match" ] && link_match=`translit_text "$notitle"` get_linkconflicts(){ linkmatch_var="$1" if [ ! -z "$linkmatch_var" ]; then grep -c ":${linkmatch_var}$" "$SCRATCH_FILE".altlinks else echo 0 fi } TOTAL_LINKCFLICTS=`get_linkconflicts "$link_match"` ALTLINK_LIST=(`cut -d":" -f 1 "$SCRATCH_FILE".altlinks`) altli=0 while [ "$TOTAL_LINKCFLICTS" -gt 1 ]; do for altl in ${ALTLINK_LIST[*]}; do altl_match=`grep -c ":${link_match}$" "$SCRATCH_FILE".altlinks` if [ "$altl_match" -gt 1 ]; then let altli=${altl_match}-1 sed -e '/'$altl':*.*/ s//'$altl':'$link_match'_'${altli}'/' "$SCRATCH_FILE".altlinks > "$SCRATCH_FILE".altlinks.new mv "$SCRATCH_FILE".altlinks.new "$SCRATCH_FILE".altlinks else altli=0 # reset counter fi done TOTAL_LINKCFLICTS=`get_linkconflicts "$link_match"` done smart_linktitle=`sed -e '/'$altlink_var':/!d; /'$altlink_var':/ s///' "$SCRATCH_FILE".altlinks` # smart linktitle failsafe and backwards compatibility [ -z "$smart_linktitle" ] || [ "$FRIENDLY_LINKS" != 1 ] && smart_linktitle="$altlink_backup" echo "$smart_linktitle" } # set link/file for given entry set_entrylink(){ entrylink_var="$1" link_type="$2" if [ "$ENTRY_ARCHIVES" = 1 ] && [ "$link_type" != altlink ]; then entrylink_var="${entrylink_var//-//}" entry_dir=${entrylink_var%%\.*} entry_dir=${entry_dir:0:10} entry_linktitle=`set_smartlinktitle "${entrylink_var//\//-}" entry` permalink_file="$entry_dir/$entry_linktitle/$NB_INDEXFILE" NB_EntryPermalink="$entry_dir/$entry_linktitle/$NB_INDEX" month=${entrylink_var:0:7} set_monthlink "$month" day=${entrylink_var:0:10} set_daylink "$day" else month=${entrylink_var:0:7} set_monthlink "$month" entrylink_id=$x_id${entrylink_var//[\/]/-} NB_EntryPermalink="$NB_ArchiveMonthLink#$entrylink_id" if [ "$DAY_ARCHIVES" = 1 ]; then day=${entrylink_var:0:10} set_daylink "$day" NB_EntryPermalink="$NB_ArchiveDayLink#$entrylink_id" fi fi } # set previous and next links for given entry set_entrynavlinks(){ entrynavlinks_type="$1" entrynavlinks_entry=`echo "$2" |grep '^[0-9].*'` case "$entrynavlinks_type" in prev) prev_entry=; NB_PrevEntryPermalink= prev_entry="$entrynavlinks_entry" ;; next) next_entry=; NB_NextEntryPermalink= next_entry="$entrynavlinks_entry" ;; esac if [ ! -z "$prev_entry" ]; then # Nijel: support for named permalinks prev_entrylink_var=${prev_entry//[-]//} prev_entry_file="${prev_entrylink_var##*.}" prev_entry_dir=${prev_entrylink_var%%\.*} prev_entry_dir=${prev_entry_dir:0:10} prev_entry_linktitle=`set_smartlinktitle "$prev_entry" entry` prev_permalink_file="$prev_entry_dir/$prev_entry_linktitle/$NB_INDEXFILE" NB_PrevEntryPermalink="$prev_entry_dir/$prev_entry_linktitle/$NB_INDEX" fi if [ ! -z "$next_entry" ]; then # Nijel: support for named permalinks next_entrylink_var=${next_entry//[-]//} next_entry_file="${next_entrylink_var##*.}" next_entry_dir=${next_entrylink_var%%\.*} next_entry_dir=${next_entry_dir:0:10} next_entry_linktitle=`set_smartlinktitle "$next_entry" entry` next_permalink_file="$next_entry_dir/$next_entry_linktitle/$NB_INDEXFILE" NB_NextEntryPermalink="$next_entry_dir/$next_entry_linktitle/$NB_INDEX" fi } # create entry archive make_entryarchive(){ if [ "$ENTRY_ARCHIVES" = 1 ]; then mkdir -p `dirname "$BLOG_DIR/$PARTS_DIR/$permalink_file"` write_template > "$BLOG_DIR/$PARTS_DIR/$permalink_file" make_page "$BLOG_DIR/$PARTS_DIR/$permalink_file" "$NB_TEMPLATE_DIR/$PERMALINK_TEMPLATE" \ "$BLOG_DIR/$ARCHIVES_DIR/$permalink_file" fi } # build entry archives build_entryarchives(){ ENTRYARCHIVES_LIST=($1) ENTRYARCHIVES_TEMPLATE="$2" ENTRYARCHIVES_DATATYPE="$3" : ${CACHE_TYPE:=entry} for entry in ${ENTRYARCHIVES_LIST[@]}; do entry=${entry%%>*} if [ -f "$NB_DATA_DIR/$entry" ]; then [ -z "$PARTS_FILE" ] && PARTS_FILE="$BLOG_DIR/$PARTS_DIR/$permalink_file" if [ "$ENTRYARCHIVES_TEMPLATE" = "$PERMALINKENTRY_TEMPLATE" ]; then set_baseurl "" "$BLOG_DIR/$ARCHIVES_DIR/$permalink_file" set_entrylink "$entry" load_entry "$NB_DATA_DIR/$entry" "$ENTRYARCHIVES_DATATYPE" "$CACHE_TYPE" year=${month:0:4} month=${month:5:2} day=${entry:8:2} findba_entries "$entry" "${MASTER_DB_RESULTS[*]}" set_entrynavlinks prev "$before_entry" set_entrynavlinks next "$after_entry" load_template "$NB_TEMPLATE_DIR/$ENTRYARCHIVES_TEMPLATE" make_entryarchive else set_baseurl "$BASE_URL" set_entrylink "$entry" load_entry "$NB_DATA_DIR/$entry" "$ENTRYARCHIVES_DATATYPE" load_template "$NB_TEMPLATE_DIR/$ENTRYARCHIVES_TEMPLATE" if [ ! -z "$TEMPLATE_DATA" ]; then mkdir -p `dirname "$PARTS_FILE"` write_template >> "$PARTS_FILE" fi fi fi done } # generate archive content make_archive(){ query_type="$1" db_catquery="$2" MKARCH_ENTRY_TEMPLATE="$3" PARTS_FILE="$4" db_setlimit="$5" db_limit="$6" db_offset="$7" query_db "$query_type" "$db_catquery" "$db_setlimit" "$db_limit" "$db_offset" ARCHIVE_LIST=(); ARCHIVE_LIST=(${DB_RESULTS[@]}) mkdir -p `dirname "$PARTS_FILE"` > "$PARTS_FILE" # fallback to default entry template [ ! -f "$NB_TEMPLATE_DIR/$MKARCH_ENTRY_TEMPLATE" ] && MKARCH_ENTRY_TEMPLATE="$ENTRY_TEMPLATE" build_entryarchives "${ARCHIVE_LIST[*]}" "$MKARCH_ENTRY_TEMPLATE" "$ARCH_DATATYPE" db_setlimit=; db_limit=; db_offset= } # divide larger archives into multiple pages paginate(){ page_query="$1" page_catquery="$2" page_items="$3" page_template="$4" page_entrytemplate="$5" page_dir="$6" page_file="$7" page_fbasedir=`dirname "$page_file"` if [ "$page_fbasedir" != . ]; then page_filedir="$page_fbasedir/" page_file=`basename "$page_file"` fi update_pages(){ build_pagelist(){ if [ ! -z "$page_num" ]; then [ -z "$PAGE_LIST" ] && PAGE_LIST="page$page_num" [ "$PAGE_LIST" != "$OLD_PAGELIST" ] && PAGE_LIST="${OLD_PAGELIST//page$page_num/} page$page_num" OLD_PAGELIST="$PAGE_LIST" fi } query_db "$page_query" "$page_catquery" limit "$page_limit" "$page_offset" PAGEMOD_VAR="$New_EntryFile$Delete_EntryFile$DeleteCatDBFile$Cat_EntryFile" for page_entry in ${UPDATE_LIST[@]}; do if [ ! -z "$PAGEMOD_VAR" ] || [ "$NB_QUERY" = all ] || [ "$page_catquery" = nocat ]; then build_pagelist else [[ ${DB_RESULTS[*]} == *$page_entry* ]] && build_pagelist fi done PAGE_LIST=`for page_n in $PAGE_LIST; do echo "$page_n"; done` } page_bynumber(){ set_baseurl "" "${page_dir}${page_filedir}$page_file" make_archive "$page_query" "$page_catquery" "$page_entrytemplate" \ "$BLOG_DIR/$PARTS_DIR/${page_filedir}$arch_file" limit "$page_limit" "$page_offset" make_page "$BLOG_DIR/$PARTS_DIR/${page_filedir}$arch_file" \ "$NB_TEMPLATE_DIR/$page_template" "${page_dir}${page_filedir}$arch_file" } query_db "$page_query" "$page_catquery" total_items=${#DB_RESULTS[*]} if [ "$total_items" -gt "$page_items" ] && [ "$page_items" != 0 ]; then get_pages(){ y=0; page_totals=($(while [ "$y" -lt "$total_items" ]; do \ let y=${page_items}+$y; echo $y; done)); echo ${#page_totals[*]}; } total_pages=`get_pages`; page_totals=0 # cleanup numbered page(s) if [ "$NB_QUERY" = all ]; then rm -f "${page_dir}${page_filedir}${page_file%%\.$NB_FILETYPE}"*[0-9]."$NB_FILETYPE" nb_msg "$paginate_action $total_pages ($page_items/$total_items) ..." else nb_msg "$paginate_action ($page_items/$total_items) ..." fi page_limit=0; page_offset=1; page_num=0 while [ "$page_num" -lt "$total_pages" ]; do let page_totals=${page_items}+$page_totals let page_offset=${page_offset}+$page_limit # if page items overflow, use difference to set new limit if [ "$page_totals" -ge "$total_items" ]; then let page_diff=${page_totals}-$total_items let page_limit=${page_limit}-$page_diff else page_limit="$page_items" fi let page_num=${page_num}+1 let prev_num=${page_num}-1 let next_num=${page_num}+1 arch_file="$page_file" arch_link="./$NB_INDEX" arch_name="${page_file%%\.*}" prev_page=`chg_suffix "$arch_name-page$prev_num".no` next_page=`chg_suffix "$arch_name-page$next_num".no` [ "$page_num" -gt 1 ] && arch_file=`chg_suffix "$arch_name-page$page_num".no` echo '' > "$SCRATCH_FILE" echo '' >> "$SCRATCH_FILE" [ "$prev_num" = 1 ] && echo '' >> "$SCRATCH_FILE" [ "$prev_num" -gt 1 ] && echo '' >> "$SCRATCH_FILE" i=1 while [ $i -le $total_pages ]; do [ "$i" = 1 ] && page="$arch_link" || page=`chg_suffix "$arch_name-page$i".no` if [ "$i" = "$page_num" ]; then echo '' >> "$SCRATCH_FILE" else echo '' >> "$SCRATCH_FILE" fi let i=${i}+1 done ! [ "$next_num" -gt "$total_pages" ] && echo '' >> "$SCRATCH_FILE" echo '' >> "$SCRATCH_FILE"; echo '
'$NB_PrevPage''$NB_PrevPage''$i''$i''$NB_NextPage'
' >> "$SCRATCH_FILE" NB_PageLinks=$(< "$SCRATCH_FILE") if [ ! -z "${UPDATE_LIST[*]}" ] || [ ! -z "$NB_QUERY" ]; then update_pages for page_mod in ${PAGE_LIST[@]}; do [ "page$page_num" = "$page_mod" ] && page_bynumber done else page_bynumber fi NB_PageLinks= done else set_baseurl "" "${page_dir}${page_filedir}$page_file" make_archive "$page_query" "$db_catquery" "$page_entrytemplate" "$BLOG_DIR/$PARTS_DIR/${page_filedir}$page_file" make_page "$BLOG_DIR/$PARTS_DIR/${page_filedir}$page_file" "$NB_TEMPLATE_DIR/$page_template" \ "${page_dir}${page_filedir}$page_file" fi ARCH_DATATYPE=; page_filedir= } # build category archives build_catarchives(){ export CACHE_TYPE=cat if [ ! -z "${CAT_LIST[*]}" ]; then for cat_arch in ${CAT_LIST[@]}; do if [ -f "$NB_DATA_DIR/$cat_arch" ]; then NB_ArchiveTitle=`nb_print "$NB_DATA_DIR/$cat_arch" 1` set_catlink "$cat_arch" [ ! -z "$CATARCH_DATATYPE" ] && ARCH_DATATYPE="$CATARCH_DATATYPE" load_plugins archive/category paginate all "$cat_arch" "$MAX_CATPAGE_ENTRIES" "$CATEGORY_TEMPLATE" \ "$CATENTRY_TEMPLATE" "$BLOG_DIR/$ARCHIVES_DIR/" "$category_file" fi done fi } # loops through archives, and executes instructions by years or months loop_archive(){ looparch_list=($1) looparch_type="$2" looparch_exec="$3" # set instructions to execute based on $looparch_type case $looparch_type in years) looparchexec_years="$looparch_exec";; months) looparchexec_months="$looparch_exec";; esac ARCHIVE_MASTER=(); ARCHIVE_YEARS=() ARCHIVE_MASTER=(${looparch_list[*]}) ARCHIVE_YEARS=(`for db_item in ${ARCHIVE_MASTER[@]}; do echo $db_item; done |cut -c1-4 |sort $SORT_ARGS`) for yearn in ${ARCHIVE_YEARS[@]}; do # execute instructions for each year if [ "$looparch_type" = years ] && [ ! -z "$looparchexec_years" ]; then $looparchexec_years else for monthn in 12 11 10 09 08 07 06 05 04 03 02 01; do ARCHIVE_MONTHS=(`for db_item in ${ARCHIVE_MASTER[@]}; do echo $db_item; done |grep $yearn'[-]'$monthn'[-]' |sed 1q`) for entry_month in ${ARCHIVE_MONTHS[@]}; do year="$yearn" month="$yearn-$monthn" query_db "$month" # execute instructions for each month if [ ! -z "${DB_RESULTS[*]}" ]; then [ ! -z "$looparchexec_months" ] && $looparchexec_months fi done done fi done } # generate the archives build_archives(){ LOOP_LIST=() load_plugins archive nb_msg "$buildarchives_action" # build/update the category archives build_catarchives if [ "$NB_QUERY" = all ]; then LOOP_LIST=(${UPDATE_LIST[*]}) else # remove duplicate entries and category indices from update list, then sort into chronological order LOOP_LIST=(`for moditem in ${UPDATE_LIST[@]}; do echo ${moditem%%>*}; done |sort $SORT_ARGS`) fi # plugins for yearly archives load_plugins archive/year # plugins month and day archives [ "$MONTH_ARCHIVES" = 1 ] && load_plugins archive/month # build entry archives export CACHE_TYPE=entry [ "$ENTRY_ARCHIVES" = 1 ] && build_entryarchives "${UPDATE_LIST[*]}" "$PERMALINKENTRY_TEMPLATE" ALL } nanoblogger-3.4.2/lib/config.sh000644 000765 000024 00000016703 11063754470 017050 0ustar00kevinwstaff000000 000000 # Module for configuration file management # Last modified: 2008-08-04T15:48:20-04:00 # --- WARNING --- # config variables that must always load # automatically set time zone using GNU specific, 'date +%z' tzd_hhmm=`date +%z` tzd_hh=${tzd_hhmm:0:3}; tzd_mm=${tzd_hhmm:3:5} AUTO_TZD=${tzd_hh}:${tzd_mm} # --- # loads global config load_globals(){ # always load global configs [ -f "$NB_CFG_DIR/nb.conf" ] && . "$NB_CFG_DIR/nb.conf" # check for user's .nb.conf in their home directory [ -f "$HOME/.nb.conf" ] && . "$HOME/.nb.conf" # default language definition : ${NB_LANG:=en} } # loads global and user configurations load_config(){ # set temp directory NB_TEMP_DIR="/tmp" # prompt to use when asking something. NB_PROMPT=": " # set deprecated BASE_DIR for temporary compatibility BASE_DIR="$NB_BASE_DIR" load_globals # allow user specified weblog directories [ ! -z "$USR_BLOGDIR" ] && BLOG_DIR="$USR_BLOGDIR" # auto-detect blog.conf from our CWD [ -z "$USR_BLOGDIR" ] || [ "$USR_BLOGDIR" = "./" ] && [ -f "$PWD/blog.conf" ] && BLOG_DIR="$PWD" BLOG_DIR="${BLOG_DIR%%\/}" # remove trailing "/" # export BLOG_DIR for the benefit of other components export BLOG_DIR : ${BLOG_CONF:="$BLOG_DIR/blog.conf"} # allow user specified weblog config files [ -f "$USR_BLOGCONF" ] && BLOG_CONF="$USR_BLOGCONF" # load weblog config file [ -f "$BLOG_CONF" ] && . "$BLOG_CONF" # set data directory [ -d "$BLOG_DIR" ] && NB_DATA_DIR="$BLOG_DIR/data" # allow user specified weblog data directories [ ! -z "$USR_DATADIR" ] && NB_DATA_DIR="$USR_DATADIR" # set template directory : ${NB_TEMPLATE_DIR:=$BLOG_DIR/templates} # allow user specified template directories [ ! -z "$USR_TEMPLATE_DIR" ] && NB_TEMPLATE_DIR="$USR_TEMPLATE_DIR" # where main plugins are located and run by default : ${PLUGINS_DIR:=$NB_BASE_DIR/plugins} # default location for user plugins : ${USR_PLUGINSDIR:=$BLOG_DIR/plugins} # default articles suffix : ${ARTICLES_SUFFIX:=txt} # --- WARNING --- # changing the following requires manually modifying # the weblog directory structure # load user defined directory to store archives ARCHIVES_DIR="$BLOG_ARCHIVES_DIR" # default directory to store archives of weblog [ -z "$ARCHIVES_DIR" ] && ARCHIVES_DIR=archives # load user defined directory to store cached data CACHE_DIR="$BLOG_CACHE_DIR" # default directory to store cached data of weblog [ -z "$CACHE_DIR" ] && CACHE_DIR=cache # load user defined directory to store parts PARTS_DIR="$BLOG_PARTS_DIR" # default directory to store parts of weblog [ -z "$PARTS_DIR" ] && PARTS_DIR=parts # default directory to store articles of weblog [ -z "$ARTICLES_DIR" ] && ARTICLES_DIR=articles # letter to prepend to entry's html id tag # WARNING: effects permanent links # load user defined id tag x_id="$BLOG_ENTRYID_TAG" : ${x_id:=e} # --- # default verbosity, 0 = silent : ${VERBOSE:=1} # default to $USER for author : ${BLOG_AUTHOR:=$USER} # allow user specified author names [ ! -z "$USR_AUTHOR" ] && BLOG_AUTHOR="$USR_AUTHOR" # default to $BROWSER then lynx for browser [ -z "$NB_BROWSER" ] && [ ! -z "$BROWSER" ] && NB_BROWSER="$BROWSER" : ${NB_BROWSER:=lynx} # export NB_BROWSER for the benefit of other components export NB_BROWSER # smart defaults for date locale if [ -n "$LC_ALL" ]; then : ${DATE_LOCALE:=$LC_ALL} elif [ -n "$LC_TIME" ]; then : ${DATE_LOCALE:=$LC_TIME} else : ${DATE_LOCALE:=$LANG} fi # default date command : ${DATE_CMD:=date} # default data file date format : ${DB_DATEFORMAT:="%Y-%m-%dT%H_%M_%S"} # default to $EDITOR first then vi [ -z "$NB_EDITOR" ] && [ ! -z "$EDITOR" ] && NB_EDITOR="$EDITOR" : ${NB_EDITOR:=vi} # export NB_EDITOR for the benefit of other components export NB_EDITOR # cleanup EDITOR/NB_EDITOR & create NB_EDITORNAME for templates if [ -z "$NB_EDITORNAME" ]; then NB_EDITORNAME="${NB_EDITOR//*\// }" NB_EDITORNAME="${NB_EDITORNAME// -*/}" fi # default file creation mask [ -z "$NB_UMASK" ] && NB_UMASK=`umask` # default to txt for datatype suffix : ${NB_DATATYPE:=txt} # default to db for database suffix : ${NB_DBTYPE:=db} # default to html for page suffix : ${NB_FILETYPE:=html} # --- WARNING --- # changing the following requires manually modifying # *all* existing entry data files! # default metadata marker (a.k.a. spacer) : ${METADATA_MARKER:=-----} # default metadata close var (e.g. 'END-----') : ${METADATA_CLOSEVAR:=END-----} # depecrated METADATA_CLOSETAG here for transitional purposes only : ${METADATA_CLOSETAG:=$METADATA_CLOSEVAR} # --- # default to raw processing for page content : ${PAGE_FORMAT:=raw} # default to raw processing for entry body : ${ENTRY_FORMAT:=raw} # default to xml for feed suffix : ${NB_SYND_FILETYPE:=xml} # default to AUTO_TZD for iso dates : ${BLOG_TZD:=$AUTO_TZD} # defaults to all for query mode : ${QUERY_MODE:=all} # set default query mode for all operations : ${NB_QUERY:=$QUERY_MODE} # set default query for main page : ${MAINPAGE_QUERY:=max} # defaults for maximum entries to display on each page : ${MAX_ENTRIES:=10} : ${MAX_PAGE_ENTRIES:=$MAX_ENTRIES} : ${MAX_CATPAGE_ENTRIES:=$MAX_PAGE_ENTRIES} : ${MAX_MONTHPAGE_ENTRIES:=$MAX_PAGE_ENTRIES} : ${MAX_MAINPAGE_ENTRIES:=$MAX_PAGE_ENTRIES} # defaults for index file name : ${NB_INDEXFILE:=index.$NB_FILETYPE} # check if we need to append directory index file to links : ${SHOW_INDEXFILE:=1} if [ "$SHOW_INDEXFILE" = 1 ]; then NB_INDEX=$NB_INDEXFILE else NB_INDEX="" fi # default for page navigation symbols (HTML entities) : ${NB_NextPage:=>} # > : ${NB_PrevPage:=<} # < : ${NB_TopPage:=/\} # /\ : ${NB_EndPage:=\/} # \/ # default to auto cache management : ${BLOG_CACHEMNG:=1} # default for maximum entries to save in cache [ -z "$MAX_CACHE_ENTRIES" ] && let MAX_CACHE_ENTRIES=${MAX_ENTRIES}*2 # default chronological order for archives : ${CHRON_ORDER:=1} # determine sort order (-u required) if [ "$CHRON_ORDER" = 1 ]; then SORT_ARGS="-ru" else SORT_ARGS="-u" fi # override configuration's interactive mode [ ! -z "$USR_INTERACTIVE" ] && BLOG_INTERACTIVE="$USR_INTERACTIVE" # default for showing permanent links : ${SHOW_PERMALINKS:=1} # deprecated PERMALINKS here for transitional purposes only : ${PERMALINKS:=$SHOW_PERMALINKS} # default for showing category links : ${SHOW_CATLINKS:=1} # depecrated CATEGORY_LINKS here for tansitional purposes only : ${CATEGORY_LINKS:=$SHOW_CATLINKS} # default for category feeds - leave unset : ${CATEGORY_FEEDS:=} # default for friendly links : ${FRIENDLY_LINKS:=1} # default limit for # of link title characters : ${MAX_TITLEWIDTH:=150} # default for archives configuration : ${ENTRY_ARCHIVES:=0} : ${MONTH_ARCHIVES:=1} : ${DAY_ARCHIVES:=0} # default for archives data : ${CATARCH_DATATYPE:=TITLE} : ${MONTHARCH_DATATYPE:=ALL} : ${DAYARCH_DATATYPE:=ALL} } # deconfigure, clear some auto-default variables deconfig(){ ARCHIVES_DIR=; CACHE_DIR=; NB_DATA_DIR=; NB_TEMPLATES_DIR=; NB_TEMP_DIR=; \ USR_PLUGINSDIR=; PARTS_DIR=; PLUGINS_DIR=; \ NB_DATATYPE=; NB_DBTYPE=; NB_FILETYPE=; NB_INDEXFILE=; NB_SYND_FILETYPE=; NB_PROMPT=; \ NB_UMASK=; \ BLOG_AUTHOR=; BLOG_CACHEMNG=; BLOG_INTERACTIVE=; BLOG_TZD=; \ CATEGORY_FEEDS=; CHRON_ORDER=; DATE_CMD=; DATE_LOCALE=; FRIENDLY_LINKS=; \ MAINPAGE_QUERY=; MAX_ENTRIES=; MAX_CACHE_ENTRIES=; MAX_CATPAGE_ENTRIES=; \ MAX_MAINPAGE_ENTRIES=; MAX_MONTHPAGE_ENTRIES=; MAX_PAGE_ENTRIES=; MAX_TITLEWIDTH=; \ METADATA_MARKER=; METADATA_CLOSEVAR=; METADATA_CLOSETAG=; \ ENTRY_FORMAT=; PAGE_FORMAT=; \ SHOW_INDEXFILE=; SHOW_PERMALINKS=; SHOW_CATLINKS=; SORT_ARGS=; \ CATARCH_DATATYPE=; DAYARCH_DATATYPE=; MONTHARCH_DATATYPE=; \ ENTRY_ARCHIVES=; DAY_ARCHIVES=; MONTH_ARCHIVES=; \ QUERY_MODE= } nanoblogger-3.4.2/lib/database.sh000644 000765 000024 00000016472 11063754470 017352 0ustar00kevinwstaff000000 000000 # Module for database functions # Last modified: 2008-07-17T22:48:03-04:00 # index related categories by id index_catids(){ indexcat_item="$1" indexcat_list=($2) [ -z "${indexcat_list[*]}" ] && indexcat_list=(`for it_db in "$NB_DATA_DIR"/cat_*.$NB_DBTYPE; do echo ${it_db//*\/}; done`) [ "$indexcat_list" = "cat_*.$NB_DBTYPE" ] && indexcat_list= cat_ids=; cat_idnum= for indexcat_db in ${indexcat_list[@]}; do CATDB_RESULTS=($(< "$NB_DATA_DIR/$indexcat_db")) for catdb_item in ${CATDB_RESULTS[@]}; do db_match=nomatch [ "${catdb_item%%>[0-9]*}" = "$indexcat_item" ] && db_match=match if [ "$db_match" = match ]; then cat_idnum="${indexcat_db/cat\_/}"; cat_idnum="${cat_idnum/\.$NB_DBTYPE/}" [ "$cat_idnum" != "$oldcat_idnum" ] && cat_idnum="$oldcat_idnum$cat_idnum" oldcat_idnum="$cat_idnum," fi done done cat_ids=; cat_idnum="${cat_idnum//\, }" [ ! -z "$cat_idnum" ] && cat_ids=">$cat_idnum" oldcat_idnum=; cat_idnum= } # rebuild main database from scratch rebuild_maindb(){ DB_YYYY=${db_query:0:4} DB_MM=${db_query:5:2} DB_DD=${db_query:8:2} : ${DB_YYYY:=[0-9][0-9][0-9][0-9]} : ${DB_MM:=[0-9][0-9]} : ${DB_DD:=[0-9][0-9]} DB_DATE="${DB_YYYY}*${DB_MM}" for db_item in "$NB_DATA_DIR"/${DB_DATE}*${DB_DD}*.$NB_DATATYPE; do if [ -f "$db_item" ]; then entry=${db_item//*\/} index_catids "$entry" [ -f "$NB_DATA_DIR/$entry" ] && echo "$entry$cat_ids" fi cat_ids= done |sort $db_order > "$SCRATCH_FILE.master.$NB_DBTYPE" cp "$SCRATCH_FILE.master.$NB_DBTYPE" "$NB_DATA_DIR/master.$NB_DBTYPE" } # split and display entry and categories from raw database results print_entry(){ echo "${1%%>[0-9]*}"; } print_cat(){ prcat_entry="${1%%>[0-9]*}" prcat_catids="${1##*\>}" [ "$prcat_entry" != "$prcat_catids" ] && echo "$prcat_catids" } # get categories for entry from main db get_catids(){ db_item="$1" db_file="$2" if [ -f "$db_file" ] && [ ! -z "$db_item" ]; then entry_match=`grep "$db_item" "$db_file"` entry_catids=`print_cat "$entry_match"` [ "$entry_catids" != "$db_item" ] && echo "$entry_catids" fi } # resort database resort_db(){ db_file="$1" db_order="$2" : ${db_order:=$SORT_ARGS} if [ -f "$db_file" ]; then sort $db_order "$db_file" > "$db_file".tmp && \ mv "$db_file".tmp "$db_file" fi } # resort category database resort_catdb(){ catdb_file="$1" db_order="$2" : ${db_order:=$SORT_ARGS} if [ -f "$catdb_file" ]; then catdb_title=`nb_print "$catdb_file" 1` echo "$catdb_title" > "$catdb_file".tmp && \ sed 1d "$catdb_file" |sort "$db_order" >> "$catdb_file".tmp && \ mv "$catdb_file".tmp "$catdb_file" fi } # resort all the databases resort_database(){ db_query=; resort_db "$NB_DATA_DIR/master.$NB_DBTYPE" for cat_db in ${db_categories[*]}; do resort_catdb "$NB_DATA_DIR/$cat_db" done } # update entry and it's related categories for main database update_maindb(){ db_item="$1" db_file="$2" if [ -f "$db_file" ] && [ ! -z "$db_item" ]; then sed -e '/'$db_item'/d' "$db_file" > "$db_file.tmp" && \ mv "$db_file".tmp "$db_file" index_catids "$db_item" [ -f "$NB_DATA_DIR/$db_item" ] && echo "$db_item$cat_ids" >> "$db_file" fi } # update entry and it's related categories for category database update_catdb(){ db_item="$1" db_file="$2" if [ -f "$db_file" ] && [ ! -z "$db_item" ]; then sed -e '/'$db_item'/d' "$db_file" > "$db_file.tmp" && \ mv "$db_file".tmp "$db_file" cat_ids=`get_catids "$db_item" "$NB_DATA_DIR/master.$NB_DBTYPE"` [ ! -z "$cat_ids" ] && cat_ids=">$cat_ids" echo "$db_item$cat_ids" >> "$db_file" cat_ids= fi } # update entry for a database update_db(){ db_item="$1" db_file="$2" if [ -f "$db_file" ] && [ ! -z "$db_item" ]; then grep_db=`grep "$db_item" "$db_file"` [ -z "$grep_db" ] && echo "$db_item" >> "$db_file" fi } # delete an entry from a database delete_db(){ db_item="$1" db_file="$2" if [ -f "$db_file" ] && [ ! -z "$db_item" ]; then grep_db=`grep "$db_item" "$db_file"` [ ! -z "$grep_db" ] && sed -e '/'$db_item'/d' "$db_file" > "$db_file".tmp && \ mv "$db_file".tmp "$db_file" fi } rebuild_catdb(){ catdb_file="$1" if [ -f "$catdb_file" ]; then catdb_title=`nb_print "$catdb_file" 1` CATDB_RESULTS=(`sed 1d "$catdb_file"`) for rbcatdb_item in ${CATDB_RESULTS[@]}; do update_catdb "$rbcatdb_item" "$catdb_file" done resort_catdb "$catdb_file" fi } # search, filter, and create makeshift and main db arrays query_db(){ db_query="$1" db_catquery="$2" db_setlimit="$3" db_limit="$4" db_offset="$5" db_order="$6" # sanitize db_limit and db_offset [[ $db_limit = *[a-z]* ]] && db_limit= [[ $db_offset = *[^0-9]* ]] && db_offset= : ${db_limit:=$MAX_ENTRIES} : ${db_limit:=0}; : ${db_offset:=1} : ${db_order:=$SORT_ARGS} : ${db_filter:=query} # adjust offset by 1 for bash arrays (1 = 0) [ "$db_offset" -ge 1 ] && ((db_offset--)) # allow /'s in queries db_query="${db_query//\//-}" # allow range of dates db_query1="${db_query%%\,*}" db_query2="${db_query##*\,}" # get list of categories or accept a user specified list if [ -z "$db_catquery" ] || [ "$db_catquery" = nocat ]; then db_catquery=; db_catvar=`echo "$NB_DATA_DIR"/cat_*.$NB_DBTYPE` [ "$db_catvar" != "cat_*.$NB_DBTYPE" ] && db_categories=(`for cat_db in "$NB_DATA_DIR"/cat_*.$NB_DBTYPE; do echo "${cat_db//*\/}"; done`) else db_categories=($db_catquery) fi [ "${db_categories[*]}" = "cat_*.$NB_DBTYPE" ] && db_categories=() query_cmd(){ if [[ "$db_query" = *[\,]* ]]; then sed -e '/'$db_query1'.*/,/'$db_query2'.*/!d' else grep "$db_query." fi } # filter_ filters filter_query(){ query_cmd |cut -d">" -f 1 |sort $db_order; } # allow for empty $db_query filter_raw(){ query_cmd |sort $db_order; } # list all entries list_db(){ # gracefully rebuild main database if [ ! -f "$NB_DATA_DIR/master.$NB_DBTYPE" ]; then db_query=; rebuild_maindb fi if [ -z "$db_catquery" ]; then grep "[\.]$NB_DATATYPE" "$NB_DATA_DIR/master.$NB_DBTYPE" else # or list entries from cat_n.db for cat_db in ${db_categories[*]}; do [ -f "$NB_DATA_DIR/$cat_db" ] && grep "[\.]$NB_DATATYPE" "$NB_DATA_DIR/$cat_db" done fi } query_data(){ if [ "$db_setlimit" = limit ]; then DB_RESULTS=(`list_db |filter_$db_filter`) [ "$db_limit" = 0 ] || [ "$db_limit" = -1 ] && db_limit=${#DB_RESULTS[*]} DB_RESULTS=(`for db_item in ${DB_RESULTS[@]:$db_offset:$db_limit}; do echo $db_item done`) else DB_RESULTS=(`list_db |filter_$db_filter`) fi } rebuild_database(){ if [ -z "$db_catquery" ]; then db_query=; rebuild_maindb else for cat_db in ${db_categories[*]}; do rebuild_catdb "$NB_DATA_DIR/$cat_db" done fi } # "main" is a special query that we redirect to MAINPAGE_QUERY [ "$db_query" = main ] && db_query="$MAINPAGE_QUERY" # "mode" is a special query that we redirect to $QUERY_MODE [ "$db_query" = mode ] && db_query="$QUERY_MODE" # initialize arrays DB_RESULTS=() case "$db_query" in a|any|all) db_query=; query_data;; # create master reference db master) db_query=; MASTER_DB_RESULTS=(); MASTER_DB_RESULTS=($(< "$NB_DATA_DIR/master.$NB_DBTYPE"));; years) db_query=; YEAR_DB_RESULTS=(); YEAR_DB_RESULTS=(`list_db |cut -c1-4 |filter_query`);; months) db_query=; MONTH_DB_RESULTS=(); MONTH_DB_RESULTS=(`list_db |cut -c1-7 |filter_query`);; days) db_query=; DAY_DB_RESULTS=(); DAY_DB_RESULTS=(`list_db |cut -c1-10 |filter_query`);; max) db_setlimit=limit; db_query=; query_data;; rebuild) rebuild_database;; *) query_data;; esac db_query=; db_filter=; db_order=; } # search, filter, and create raw db references raw_db(){ db_filter=raw query_db "$1" "$2" "$3" "$4" "$5" "$6" } nanoblogger-3.4.2/lib/error.sh000644 000765 000024 00000000320 10504303605 016705 0ustar00kevinwstaff000000 000000 # Module for error handling # Last modified: 2006-09-20T13:57:26-04:00 # function to die with a message die(){ cat <<-EOF $@ EOF exit 1 } nb_msg(){ if [ "$VERBOSE" != 0 ]; then cat <<-EOF $@ EOF fi } nanoblogger-3.4.2/lib/tools.sh000644 000765 000024 00000055677 11336060051 016744 0ustar00kevinwstaff000000 000000 # Module for utility functions # Last modified: 2010-02-14T15:15:35-05:00 # simple command evaluator that attempts to mask output nb_eval(){ DEVNULL=`eval "$1" 2>&1` return $? } # create a semi ISO 8601 formatted timestamp for archives # used explicitly, please don't edit unless you know what you're doing. nb_timestamp(){ $DATE_CMD $DB_DATEARGS +"$DB_DATEFORMAT"; } # convert to a more printable date format filter_timestamp(){ #echo "$1" |sed -e '/[\_]/ s//:/g; /[A-Z]/ s// /g' entry_date=${1%%.$NB_DATATYPE}; entry_date=${entry_date//\_/:} echo ${entry_date//[A-Z]/ } } # reverse filter time stamp to original form refilter_timestamp(){ #echo "$1" |sed -e '/[\:]/ s//_/g; /[ ]/ s//T/' entry_date=${1//\:/_} echo ${entry_date//[ ]/T} } # validate time stamp validate_timestamp(){ echo "$1" |grep '^[0-9][0-9][0-9][0-9][\-][0-9][0-9][\-][0-9][0-9][A-Z][0-9][0-9][\_][0-9][0-9][\_][0-9][0-9]$' } # filter custom date format for a new entry # synopsis: filter_dateformat [date] [date args] filter_dateformat(){ FILTER_DATE="$1" FILTER_ARGS="$2" : ${FILTER_ARGS:=$DATE_ARGS} # use date's defaults, when no date format is specified if [ ! -z "$FILTER_DATE" ]; then [ ! -z "$DATE_LOCALE" ] && LC_ALL="$DATE_LOCALE" $DATE_CMD $FILTER_ARGS +"$FILTER_DATE" [ -z "$DATE_LOCALE" ] && $DATE_CMD $FILTER_ARGS +"$FILTER_DATE" else [ ! -z "$DATE_LOCALE" ] && LC_ALL="$DATE_LOCALE" $DATE_CMD $FILTER_ARGS [ -z "$DATE_LOCALE" ] && $DATE_CMD $FILTER_ARGS fi } # filter custom date string using GNU specific 'date -d' # synopsis: filter_datestring [date] [date args] [date description] filter_datestring(){ FILTER_DATE="$1" FILTER_ARGS="$2" FILTER_DESC="$3" : ${FILTER_ARGS:=$DATE_ARGS} if [ ! -z "$DATE_FORMAT" ]; then [ ! -z "$DATE_LOCALE" ] && LC_ALL="$DATE_LOCALE" $DATE_CMD +"$DATE_FORMAT" $DATE_ARGS -d "$FILTER_DESC" [ -z "$DATE_LOCALE" ] && $DATE_CMD +"$DATE_FORMAT" $DATE_ARGS -d "$FILTER_DESC" else [ ! -z "$DATE_LOCALE" ] && LC_ALL="$DATE_LOCALE" $DATE_CMD $DATE_ARGS -d "$FILTER_DESC" [ -z "$DATE_LOCALE" ] && $DATE_CMD $DATE_ARGS -d "$FILTER_DESC" fi } # change suffix of file chg_suffix(){ filename="$1" suffix="$2" old_suffix="${filename##*.}" [ ! -z "$suffix" ] && NB_FILETYPE="$suffix" echo "${filename//[\.]$old_suffix/.$NB_FILETYPE}" } # tool to require confirmation confirm_action(){ echo "$confirmaction_ask [y/N]" read -p "$NB_PROMPT" confirm case $confirm in [Yy]);; [Nn]|"") die;; esac } # sensible-browser-like utility (parses $NB_BROWSER, $BROWSER, and %s) # synopsis: nb_browser [url] # NOTE: $BROWSE_URL must be full path or some browsers complain nb_browser(){ BROWSER_CMD="$NB_BROWSER" BROWSER_URL="$1" if [ ! -z "$BROWSER_CMD" ]; then BROWSER_LIST=`echo "$BROWSER_CMD" |sed -e '/[ ]/ s//%REM%/g; /\:/ s// /g'` for browser in $BROWSER_LIST; do browserurl_sedvar="${BROWSER_URL//\//\\/}" browser_cmd=`echo "$browser" |sed -e 's/\%REM\%/ /g; s/\%\%/\%/g; s/\%s/'$browserurl_sedvar'/g'` nb_msg "$nbbrowser_running $browser_cmd $BROWSER_URL ..." eval $browser_cmd "$BROWSER_URL" && break # on failure, continue to next in list done if [ $? != 0 ]; then nb_msg "$nbbrowser_nobrowser" fi fi } # wrapper to editor command # synopsis: nb_edit [options] file nb_edit(){ EDIT_OPTIONS="$1" EDIT_FILE="$2" [ -z "$EDIT_FILE" ] && EDIT_FILE="$1" # set directory being written to EDIT_DIR="${EDIT_FILE%%\/${EDIT_FILE##*\/}}" # assume current directory when no directory is found [ ! -d "$EDIT_DIR" ] && EDIT_DIR="./" # test directory for write permissions [ ! -w "$EDIT_DIR" ] && [ -d "$EDIT_DIR" ] && die "'$EDIT_DIR' - $nowritedir" case "$EDIT_OPTIONS" in -p) # prompt to continue (kludge for editors that detach from process) eval $NB_EDITOR "$EDIT_FILE" read -p "$nbedit_prompt" enter_key ;; *) # default action eval $NB_EDITOR "$EDIT_FILE" ;; esac if [ ! -f "$EDIT_FILE" ]; then nb_msg "'$EDIT_FILE' - $nbedit_nofile" die "'$EDIT_FILE' - $nbedit_failed" fi } # print a file (line by line) # synopsis: nb_print file [number of lines|blank for all] nb_print(){ nbprint_file="$1" maxnbprint_cnt=$2 nbprint_cnt=0 while read line; do let nbprint_cnt=${nbprint_cnt}+1 [ ! -z $maxnbprint_cnt ] && [ $nbprint_cnt -gt $maxnbprint_cnt ] && break echo $line done < $nbprint_file } # convert category number to existing cateogory database cat_id(){ cat_query=(`echo "$1" |grep '[0-9]' |sed -e '/,/ s// /g; /[A-Z,a-z\)\.-]/d'`) query_db if [ ! -z "${cat_query[*]}" ]; then for cat_id in ${cat_query[@]}; do cat_valid=`for cat_db in ${db_categories[@]}; do echo $cat_db; done |grep cat_$cat_id.$NB_DBTYPE` echo "$cat_valid" [ -z "$cat_valid" ] && nb_msg "$catid_bad" done fi } # validate category's id number check_catid(){ cat_list=(`cat_id "$1"`) for cat_db in ${cat_list[@]}; do [ ! -f "$NB_DATA_DIR/$cat_db" ] && die "$checkcatid_invalid $1" done [ ! -z "$1" ] && [ -z "${cat_list[*]}" ] && die "$checkcatid_novalid" } # check file for required metadata vars check_metavars(){ VALIDATE_VARS="$1" VALIDATE_METAFILE="$2" for mvar in $VALIDATE_VARS; do MVAR_NUM=`grep -c "^$mvar" "$VALIDATE_METAFILE"` [ "$MVAR_NUM" = 0 ] && die "'$VALIDATE_METAFILE' - $checkmetavars_novar '$mvar'" done } # import metafile import_file(){ IMPORT_FILE="$1" if [ -f "$IMPORT_FILE" ]; then # validate metafile check_metavars "TITLE: AUTHOR: DATE: BODY: $METADATA_CLOSEVAR" \ "$IMPORT_FILE" load_metadata ALL "$IMPORT_FILE" load_metadata HEADERS "$IMPORT_FILE" else die "'$IMPORT_FILE' $importfile_nofile" fi } # transliterate text into a suitable form for web links translit_text(){ translittext_var="$1"; ttchar_limit=${MAX_TITLEWIDTH} nonascii="${translittext_var//[a-zA-Z0-9_-]/}" # isolate all non-printable/non-ascii characters echo "${translittext_var:0:$ttchar_limit}" |sed -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/; s/[\`\~\!\@\#\$\%\^\*\(\)\+\=\{\}\|\\\;\:\'\"\,\<\>\/\?]//g; s/ [\&] / and /g; s/^[ ]//g; s/[ ]$//g; s/[\.]/_/g; s/\[//g; s/\]//g; s/ /_/g; s/[$nonascii ]/_/g" |sed -e '/[\_\-]*$/ s///g; /[\_\-]$/ s///g' } # tool to lookup ID from master database lookup_id(){ INPUT_IDLIST=($2) for db_item in ${INPUT_IDLIST[@]}; do echo $db_item done |grep -n "$1" |cut -d":" -f 1 |grep '^[0-9].*$' } # tool to find entry before and after from entry's id findba_entries(){ BAENTRY_IDLIST=($2) entryid_var=`lookup_id "$1" "${BAENTRY_IDLIST[*]}"` # adjust offset by 1 for bash arrays (1 = 0) ((entryid_var--)) # determine direction based on chronological date order if [ "$CHRON_ORDER" = 1 ]; then let before_entryid=${entryid_var}+1 let after_entryid=${entryid_var}-1 else let before_entryid=${entryid_var}-1 let after_entryid=${entryid_var}+1 fi if [ "$before_entryid" -ge 0 ]; then before_entry=${BAENTRY_IDLIST[$before_entryid]%%\>[0-9]*} else before_entry= fi if [ "$after_entryid" -ge 0 ]; then after_entry=${BAENTRY_IDLIST[$after_entryid]%%\>[0-9]*} else after_entry= fi } # tool to build list of related categories from list of entries find_categories(){ FIND_CATLIST=($1) cat_list=() build_catlist(){ [ ! -z "$cat_var" ] && cat_list=( ${cat_list[@]} $cat_db ) } # acquire all the categories for relative_entry in ${FIND_CATLIST[@]}; do raw_db "$relative_entry" cat_ids=`print_cat "${DB_RESULTS[*]}"` cat_ids="${cat_ids//\,/ }" for cat_id in $cat_ids; do cat_var="$cat_id" cat_db="cat_$cat_id.$NB_DBTYPE" build_catlist done cat_id=; cat_ids=; cat_var=; cat_db=; done CAT_LIST=( ${cat_list[@]} ) [ -z "${CAT_LIST[*]}" ] && [ ! -z "$cat_num" ] && CAT_LIST=( `cat_id "$cat_num"` ) [ "$UPDATE_WEBLOG" = 1 ] && [ "$NB_QUERY" = all ] && [ -z "$cat_num" ] && CAT_LIST=${db_categories[@]} CAT_LIST=(`for cat_id in ${CAT_LIST[@]}; do echo "$cat_id"; done |sort -u`) } # resort category databases from list resort_categories(){ RESORT_CATDBLIST=($1) [ -z "${RESORT_CATDBLIST[*]}" ] && RESORT_CATDBLIST=(${CAT_LIST[*]}) for mod_catdb in ${CAT_LIST[@]}; do resort_catdb "$NB_DATA_DIR/$mod_catdb" done } # update categories with cateogory id's from main db with list of entries update_categories(){ UPDATE_CATLIST=($1) [ -z "${UPDATE_CATLIST[*]}" ] && UPDATE_CATLIST=(${UPDATE_LIST[*]}) for ucat_entry in ${UPDATE_CATLIST[@]}; do cat_ids=`get_catids "$ucat_entry" "$NB_DATA_DIR/master.$NB_DBTYPE"` cat_ids="${cat_ids//\,/ }" for cat_id in $cat_ids; do cat_var="$cat_id" cat_db="cat_$cat_id.$NB_DBTYPE" update_catdb "$ucat_entry" "$NB_DATA_DIR/$cat_db" done cat_id=; cat_ids=; cat_var=; cat_db=; done } # generate timestamp as metadata variables meta_timestamp(){ NB_MetaDate=`filter_dateformat "$DATE_FORMAT"` NB_MetaTimeStamp=`nb_timestamp` # fallback to printable timestamp if [ -z "$NB_MetaDate" ]; then nb_msg "$filter_datefailed" NB_MetaDate=`filter_timestamp "$NB_MetaTimeStamp"` fi } # read file's metadata read_metadata(){ META_FILE="$2" MVAR_CLOSE=`echo "$1" |sed -e '/[^ ].*[\,]/ s///'` if [ "$1" != "$MVAR_CLOSE" ] && [ ! -z "$MVAR_CLOSE" ]; then MVAR=`echo "$1" |sed -e '/[\,].*[^ ]$/ s///'` METADATA=`sed -e '/^'$MVAR'[\:]/,/^'$MVAR_CLOSE'/!d; /^'$MVAR'[\:]/d; /^'$MVAR_CLOSE'/d' "$META_FILE"` else METADATA=`sed -e '/^'$1'[\:]/!d; /^'$1'[\:] */ s///' "$META_FILE"` fi } # load metadata from file into tangible shell variables load_metadata(){ METADATA_TYPE="$1" # ALL, NOBODY, or valid metadata key METADATA_FILE="$2" [ ! -f "$METADATA_FILE" ] && die "'$METADATA_FILE' $importfile_nofile" case $METADATA_TYPE in AUTHOR) read_metadata AUTHOR "$METADATA_FILE"; NB_MetaAuthor="$METADATA" NB_EntryAuthor="$NB_MetaAuthor";; BODY|CONTENT) read_metadata "BODY,$METADATA_CLOSEVAR" "$METADATA_FILE"; NB_MetaBody="$METADATA" NB_EntryBody="$NB_MetaBody";; DATE) read_metadata DATE "$METADATA_FILE"; NB_MetaDate="$METADATA" NB_EntryDate="$NB_MetaDate";; DESC) NB_EntryDescription="$NB_MetaDescription" read_metadata FORMAT "$METADATA_FILE"; NB_MetaFormat="$METADATA";; FORMAT) read_metadata FORMAT "$METADATA_FILE"; NB_MetaFormat="$METADATA" NB_EntryFormat="$NB_MetaFormat";; HEADERS) : ${METADATA_MARKER:=-----} : ${METADATA_CLOSEVAR:=END-----} METADATA_HEADERS=`sed -e '1,/^'$METADATA_MARKER'/!d; /^'$METADATA_MARKER'/d' "$METADATA_FILE"` METADATA_CONTENT=`sed -e '/^'$METADATA_MARKER'/,/^'$METADATA_CLOSEVAR'/!d' "$METADATA_FILE"`;; TITLE) read_metadata TITLE "$METADATA_FILE"; NB_MetaTitle="$METADATA" NB_EntryTitle="$NB_MetaTitle";; ALL) for LMDATATYPE in AUTHOR TITLE DATE DESC FORMAT BODY; do load_metadata $LMDATATYPE "$METADATA_FILE" done;; NOBODY) for LMDATATYPE in AUTHOR TITLE DATE DESC FORMAT; do load_metadata $LMDATATYPE "$METADATA_FILE" done;; *) load_metadata ALL "$METADATA_FILE";; esac } # write metadata out to file write_metadata(){ WRITE_MDATA="$2" META_FILE="$3" MVAR_CLOSE=`echo "$1" |sed -e '/[^ ].*[\,]/ s///'` if [ ! -z "$1" ] && [ ! -z "$WRITE_MDATA" ]; then if [ "$1" != "$MVAR_CLOSE" ] && [ ! -z "$MVAR_CLOSE" ]; then MVAR=`echo "$1" |sed -e '/[\,].*[^ ]$/ s///'` if [ -f "$META_FILE" ]; then META_OTHER=`sed -e '/^'$MVAR'[\:]/,/^'$MVAR_CLOSE'/d; /^'$MVAR'[\:]/d; /^'$MVAR_CLOSE'/d' "$META_FILE"` fi cat > "$META_FILE" <<-EOF $META_OTHER $MVAR: $WRITE_MDATA $MVAR_CLOSE EOF elif [ -f "$META_FILE" ]; then METAVAR_MATCH=`grep "^$1[\:]" "$META_FILE"` # first, try replacing meta-tag, while preserving structure if [ ! -z "$METAVAR_MATCH" ]; then load_metadata HEADERS "$META_FILE" SAVED_METADATACONTENT="$METADATA_CONTENT" if [ ! -z "$METADATA_HEADERS" ]; then # prevent command line substutition and shell variable expansion in titles read_metadata TITLE "$META_FILE"; NB_MetaTitle="$METADATA" if [ ! -z "$METADATA" ]; then sed -e '/^TITLE[\:].*/ s//TITLE: \$NB_MetaTitle/g' > "$META_FILE" <<-EOF $METADATA_HEADERS EOF fi load_metadata HEADERS "$META_FILE" sed -e '/^'$1'[\:].*/ s//'$1': \$NB_MetaOther/g' > "$META_FILE" <<-EOF $METADATA_HEADERS EOF NB_MetaOther="$WRITE_MDATA" # expands all variables in METADATA_HEADERS load_template "$META_FILE" write_template > "$META_FILE" echo "$SAVED_METADATACONTENT" >> "$META_FILE" fi else # second, try stacking new/modified meta-tag on top, disregarding structure, # while preserving data META_OTHER=`sed -e '/^'$1'[\:]/d' "$META_FILE"` cat > "$META_FILE" <<-EOF $1: $WRITE_MDATA $META_OTHER EOF fi fi fi } # create/modify user metadata field write_var(){ WRITE_MVAR="$1" WRITE_MVARVALUE="$2" WRITEMETAVAR_FILE="$3" [ ! -z "$USR_METAVAR" ] && WRITE_MVAR="$USR_METAVAR" [ ! -z "$USR_SETVAR" ] && WRITE_MVARVALUE="$USR_SETVAR" if [ ! -z "$WRITE_MVAR" ]; then write_metadata "$WRITE_MVAR" "$WRITE_MVARVALUE" \ "$WRITEMETAVAR_FILE" fi } # write entry's metadata to file write_entry(){ WRITE_ENTRY_FILE="$1" # help ease transition from 3.2.x or earlier [ ! -f "$NB_TEMPLATE_DIR/$METADATAENTRY_TEMPLATE" ] && cp "$NB_BASE_DIR/default/templates/$METADATAENTRY_TEMPLATE" "$NB_TEMPLATE_DIR" NB_EntryBody="$NB_MetaBody" # set here for entry template load_template "$NB_TEMPLATE_DIR/$METADATAENTRY_TEMPLATE" mkdir -p `dirname "$WRITE_ENTRY_FILE"` write_template > "$WRITE_ENTRY_FILE" write_var "$USR_METAVAR" "$USR_SETVAR" "$WRITE_ENTRY_FILE" } # load entry from it's metadata file load_entry(){ ENTRY_FILE="$1" ENTRY_DATATYPE="$2" ENTRY_CACHETYPE="$3" : ${ENTRY_PLUGINSLOOP:=shortcode entry/mod entry/format entry} : ${ENTRY_DATATYPE:=ALL} if [ -f "$ENTRY_FILE" ]; then entry_day=${entry:8:2} entry_time=`filter_timestamp "$entry"` entry_time=${entry_time:11:8} if [ -z "$ENTRY_CACHETYPE" ]; then if [ ! -z "$CACHE_TYPE" ]; then ENTRY_CACHETYPE="$CACHE_TYPE" else ENTRY_CACHETYPE=metadata fi fi if [ "$ENTRY_DATATYPE" != ALL ] || [ "$ENTRY_DATATYPE" = NOBODY ]; then NB_EntryID=$x_id${entry//[\/]/-} load_metadata "$ENTRY_DATATYPE" "$ENTRY_FILE" load_plugins entry else NB_EntryID=$x_id${entry//[\/]/-} # use cache when entry data unchanged if [ "$ENTRY_FILE" -nt "$BLOG_DIR/$CACHE_DIR/$entry.$ENTRY_CACHETYPE" ]; then #nb_msg "UPDATING CACHE - $entry.$ENTRY_CACHETYPE" load_metadata ALL "$ENTRY_FILE" for entry_pluginsdir in $ENTRY_PLUGINSLOOP; do if [ "$entry_pluginsdir" = "entry/format" ]; then [ -z "$NB_EntryFormat" ] && NB_EntryFormat="$ENTRY_FORMAT" load_plugins $entry_pluginsdir "$NB_EntryFormat" else load_plugins $entry_pluginsdir fi done write_entry "$BLOG_DIR/$CACHE_DIR/$entry.$ENTRY_CACHETYPE" # update cache list for some post-cache management #update_cache build $ENTRY_CACHETYPE "$entry" else #nb_msg "LOADING CACHE - $entry.$ENTRY_CACHETYPE" load_metadata ALL "$BLOG_DIR/$CACHE_DIR/$entry.$ENTRY_CACHETYPE" load_plugins entry fi fi fi } # create file with metadata fields make_file(){ WRITE_META_FILE="$1" WRITE_META_TEMPLATE="$2" # defaults to metafile template [ -z "$WRITE_META_TEMPLATE" ] && WRITE_META_TEMPLATE="$NB_TEMPLATE_DIR/$METADATAFILE_TEMPLATE" # help ease transition from 3.2.x or earlier [ ! -f "$NB_TEMPLATE_DIR/$METADATAFILE_TEMPLATE" ] && cp "$NB_BASE_DIR/default/templates/$METADATAFILE_TEMPLATE" "$NB_TEMPLATE_DIR" # accept user metadata [ ! -z "$USR_AUTHOR" ] && NB_MetaAuthor="$USR_AUTHOR" [ -z "$NB_MetaAuthor" ] && NB_MetaAuthor="$BLOG_AUTHOR" [ ! -z "$USR_DESC" ] && NB_MetaDescription="$USR_DESC" if [ ! -z "$USR_TITLE" ]; then NB_MetaTitle="$USR_TITLE"; USR_TITLE= fi [ ! -z "$USR_TEXT" ] && NB_MetaBody="$USR_TEXT" meta_timestamp load_template "$WRITE_META_TEMPLATE" write_template > "$WRITE_META_FILE" write_var "$USR_METAVAR" "$USR_SETVAR" "$WRITE_META_FILE" } # create weblog page from text (parts) files make_page(){ MKPAGE_SRCFILE="$1" MKPAGE_TEMPLATE="$2" MKPAGE_OUTFILE="$3" if [ -z "$MKPAGE_TITLE" ] && [ ! -z "$USR_TITLE" ]; then MKPAGE_TITLE="$USR_TITLE"; USR_TITLE= fi if [ ! -z "$MKPAGE_TITLE" ]; then NB_MetaTitle="$MKPAGE_TITLE" # Set NB_EntryTitle for backwards compatibility NB_EntryTitle="$MKPAGE_TITLE" fi [ ! -z "$USR_TEMPLATE" ] && MKPAGE_TEMPLATE="$USR_TEMPLATE" [ -z "$MKPAGE_TEMPLATE" ] && MKPAGE_TEMPLATE="$NB_TEMPLATE_DIR/$MAKEPAGE_TEMPLATE" [ ! -f "$MKPAGE_SRCFILE" ] && die "'$MKPAGE_SRCFILE' - $makepage_nosource" [ -z "$MKPAGE_OUTFILE" ] && die "'$MKPAGE_OUTFILE' - $makepage_nooutput" [ ! -f "$MKPAGE_TEMPLATE" ] && die "'$MKPAGE_TEMPLATE' - $makepage_notemplate" # make sure the output directory is present before writing to it mkdir -p `dirname "$MKPAGE_OUTFILE"` set_baseurl "" "$MKPAGE_OUTFILE" # load file as content : ${MKPAGE_CONTENT:=$(< "$MKPAGE_SRCFILE")} # let plugins modify the content load_plugins page : ${MKPAGE_FORMAT:=$PAGE_FORMAT} load_plugins page/format "$MKPAGE_FORMAT" NB_MetaBody="$MKPAGE_CONTENT"; NB_Entries="$MKPAGE_CONTENT" # leave here for backwards compatibility load_template "$MKPAGE_TEMPLATE" mkdir -p `dirname "$MKPAGE_OUTFILE"` write_template > "$MKPAGE_OUTFILE" nb_msg "$MKPAGE_OUTFILE" load_plugins makepage MKPAGE_CONTENT=; MKPAGE_FORMAT=; MKPAGE_TITLE=; NB_MetaTitle=; NB_EntryTitle= } # creates weblog page from metafile weblog_page(){ BLOGPAGE_SRCFILE="$1" BLOGPAGE_TEMPLATE="$2" BLOGPAGE_OUTFILE="$3" [ ! -z "$USR_TEMPLATE" ] && BLOGPAGE_TEMPLATE="$USR_TEMPLATE" if [ -f "$BLOGPAGE_SRCFILE" ]; then write_var "$USR_METAVAR" "$USR_SETVAR" "$BLOGPAGE_SRCFILE" load_metadata ALL "$BLOGPAGE_SRCFILE" [ ! -z "$USR_AUTHOR" ] && NB_MetaAuthor="$USR_AUTHOR" [ -z "$NB_MetaAuthor" ] && NB_MetaAuthor="$BLOG_AUTHOR" [ ! -z "$USR_DESC" ] && NB_MetaDescription="$USR_DESC" [ ! -z "$USR_TITLE" ] && NB_MetaTitle="$USR_TITLE" [ ! -z "$USR_TEXT" ] && NB_MetaBody="$USR_TEXT" for weblogpage_plugin in shortcode page/mod; do load_plugins $weblogpage_plugin done MKPAGE_CONTENT="$NB_MetaBody" MKPAGE_FORMAT="$NB_MetaFormat" : ${MKPAGE_FORMAT:=$BLOGPAGE_FORMAT} make_page "$BLOGPAGE_SRCFILE" "$BLOGPAGE_TEMPLATE" "$BLOGPAGE_OUTFILE" fi } # edit draft file nb_draft(){ EDITDRAFT_OPTIONS="$1" EDITDRAFT_FILE="$2" [ -z "$EDITDRAFT_FILE" ] && EDITDRAFT_FILE="$1" [ ! -z "$USR_DRAFTFILE" ] && EDITDRAFT_FILE="$USR_DRAFTFILE" if [ ! -z "$EDITDRAFT_FILE" ] && [ ! -f "$EDITDRAFT_FILE" ]; then echo "'$EDITDRAFT_FILE' - $nbdraft_asknew [Y/n]" read -p "$NB_PROMPT" choice case $choice in [Yy]|"") make_file "$EDITDRAFT_FILE" "$USR_TEMPLATE";; [Nn]) ;; esac fi if [ -f "$EDITDRAFT_FILE" ]; then write_var "$USR_METAVAR" "$USR_SETVAR" "$EDITDRAFT_FILE" nb_edit "$EDITDRAFT_OPTIONS" "$EDITDRAFT_FILE" # validate metafile check_metavars "TITLE: BODY: $METADATA_CLOSEVAR" "$EDITDRAFT_FILE" # modify date (DATE metadata) meta_timestamp && write_metadata DATE "$NB_MetaDate" "$EDITDRAFT_FILE" fi } preview_weblog(){ if [ "$NOPREVIEW_WEBLOG" != 1 ] || [ "$PREVIEW_WEBLOG" = 1 ]; then [ -z "$BLOG_PREVIEW_CMD" ] && die "$preview_nocmd" if [ "$BLOG_INTERACTIVE" = 1 ]; then echo "$preview_asknow [y/N]" read -p "$NB_PROMPT" choice case $choice in [Yy]) nb_msg "$preview_action" $BLOG_PREVIEW_CMD;; [Nn]|"") ;; esac else nb_msg "$preview_action" $BLOG_PREVIEW_CMD fi fi } publish_weblog(){ if [ "$NOPUBLISH_WEBLOG" != 1 ] || [ "$PUBLISH_WEBLOG" = 1 ]; then [ -z "$BLOG_PUBLISH_CMD" ] && die "$publish_nocmd" if [ "$BLOG_INTERACTIVE" = 1 ]; then echo "$publish_asknow [y/N]" read -p "$NB_PROMPT" choice case $choice in [Yy]) nb_msg "$publish_action" $BLOG_PUBLISH_CMD;; [Nn]|"") ;; esac else nb_msg "$publish_action" $BLOG_PUBLISH_CMD fi fi } # tool to help manage the cache update_cache(){ cache_update="$1" cache_def="$2" CACHEUPDATE_LIST=($3) # pre-processing for extensive update-cache options if [ "$UPDATE_WEBLOG" = 1 ]; then updcache_type="$updweblog_type" updatec_idsel="$update_idsel" fi if [ "$QUERY_WEBLOG" != 1 ] && [ -z "$cache_update" ]; then cache_update="$updcache_type" fi [ -z "$cache_update" ] && cache_update=expired [ ! -z "$cat_num" ] && cache_update=rebuild case "$updcache_type" in tag|tag[a-z]) cache_update=rebuild; cat_num="$updatec_idsel" db_catquery=`cat_id "$cat_num"`; check_catid "$cat_num" esac case "$cache_update" in build) [ -z "$cache_def" ] && cache_def="*" if [ -z "${CACHEUPDATE_LIST[*]}" ]; then query_db "$db_query" "$db_catquery" CACHEUPDATE_LIST=(${DB_RESULTS[*]}) fi for cache_item in ${CACHEUPDATE_LIST[@]}; do echo "$cache_item" >> "$SCRATCH_FILE".cache_list.tmp done CACHEUPDATE_LIST=($(< "$SCRATCH_FILE".cache_list.tmp));; rebuild) > "$SCRATCH_FILE".cache_list.tmp [ -z "$cache_def" ] && cache_def="*" if [ -z "${CACHEUPDATE_LIST[*]}" ]; then query_db "$db_query" "$db_catquery" CACHEUPDATE_LIST=(${DB_RESULTS[*]}) fi for cache_item in ${CACHEUPDATE_LIST[@]}; do echo "$cache_item" >> "$SCRATCH_FILE".cache_list.tmp rm -f "$BLOG_DIR/$CACHE_DIR/$cache_item".$cache_def done CACHEUPDATE_LIST=($(< "$SCRATCH_FILE".cache_list.tmp));; expired) [ -z "$cache_def" ] && cache_def="*" # always cache more recent entries [ "$CHRON_ORDER" != 1 ] && db_order="-ru" query_db all "$db_catquery" limit "$MAX_CACHE_ENTRIES" "" "$db_order" for cache_item in "$BLOG_DIR/$CACHE_DIR"/*.$cache_def; do cache_item=${cache_item##*\/} cache_regex="${cache_item%%\.$cache_def*}" cache_match=`echo "${DB_RESULTS[*]}" |grep -c "$cache_regex"` [ "$cache_match" = 0 ] && rm -f "$BLOG_DIR/$CACHE_DIR/$cache_item" done;; *) [ -z "$cache_def" ] && cache_def="*" [ ! -z "$cache_update" ] && query_db "$cache_update" "$db_catquery" for cache_item in ${DB_RESULTS[@]}; do rm -f "$BLOG_DIR/$CACHE_DIR/$cache_item".$cache_def done;; esac [ ! -z "${CACHEUPDATE_LIST[*]}" ] && CACHE_LIST=(`for cache_item in ${CACHEUPDATE_LIST[@]}; do echo $cache_item; done |sort -u`) } # tool to help change an entry's date/timestamp # (e.g. TIMESTAMP: YYYY-MM-DD HH:MM:SS) chg_entrydate(){ EntryDate_File="$1" EntryDate_TimeStamp="$2" # read timestamp from command line [ "$USR_METAVAR" = TIMESTAMP ] && EntryDate_TimeStamp="$USR_SETVAR" # validate timestamp format Edit_EntryTimeStamp=`refilter_timestamp "$EntryDate_TimeStamp"` New_EntryTimeStamp=`validate_timestamp "$Edit_EntryTimeStamp"` # abort if we don't have a valid timestamp [ ! -z "$EntryDate_TimeStamp" ] && [ -z "$New_EntryTimeStamp" ] && die "$novalid_entrytime" if [ ! -z "$New_EntryTimeStamp" ]; then [ ! -f "$SCRATCH_FILE.mod-catdbs" ] && > "$SCRATCH_FILE.mod-catdbs" New_EntryDateFile="$New_EntryTimeStamp.$NB_DATATYPE" # abort if a possible conflict arises [ -f "$NB_DATA_DIR/$New_EntryDateFile" ] && die "$invalid_entrytime" if [ -f "$NB_DATA_DIR/$EntryDate_File" ] && [ "$EntryDate_File" != "$New_EntryDateFile" ]; then Old_EntryFile="$EntryDate_File" mv "$NB_DATA_DIR/$Old_EntryFile" "$NB_DATA_DIR/$New_EntryDateFile" set_entrylink "$Old_EntryFile" Delete_PermalinkFile="$BLOG_DIR/$ARCHIVES_DIR/$permalink_file" Delete_PermalinkDir="$BLOG_DIR/$ARCHIVES_DIR/$entry_dir" # delete old permalink file [ -f "$Delete_PermalinkFile" ] && rm -fr "$Delete_PermalinkFile" # delete old permalink directory [ ! -z "$entry_dir" ] && [ -d "$Delete_PermalinkDir" ] && rm -fr "$Delete_PermalinkDir" # delete the old cache data rm -f "$BLOG_DIR/$CACHE_DIR/$Old_EntryFile".* fi NEWDATE_STRING=`echo "$New_EntryTimeStamp" |sed -e 's/[A-Z,a-z]/ /g; s/[\_]/:/g'` NB_NewEntryDate=$(filter_datestring "$DATE_FORMAT" "" "$NEWDATE_STRING") if [ ! -z "$NB_NewEntryDate" ]; then write_metadata DATE "$NB_NewEntryDate" "$NB_DATA_DIR/$New_EntryDateFile" else # fallback to timestamp nb_msg "$filterdate_failed" NB_NewEntryDate="$EntryDate_TimeStamp" write_metadata DATE "$NB_NewEntryDate" "$NB_DATA_DIR/$New_EntryDateFile" fi fi } nanoblogger-3.4.2/lang/en/000755 000765 000024 00000000000 11336333422 016006 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/lang/en/help.txt000644 000765 000024 00000007076 11237664552 017524 0ustar00kevinwstaff000000 000000 NanoBlogger - Command line weblog engine. Version $VERSION, Copyright $COPYRIGHT Kevin Wood NanoBlogger comes with ABSOLUTELY NO WARRANTY; see version 2 of the GNU General Public License for further details Usage: $BASENAME [-b blog_dir] [options] Actions: add [article|entry|tag|weblog] - create new article, entry, tag, or weblog (directory). configure - configure weblog (for 'update'). delete [entry|tag] - delete entry, tag, or un-tag entry. draft - create and edit meta-file. edit [[entry|tag] ]|file ] - edit entry, meta-file or tag. list [all|tags|DATE|max|tag ] - list entries or tags (defaults to 'all'). import [article|entry] - import new article or entry from meta-file. make-file - create new meta-file. make-page - create new weblog page (file2) from meta-file (file1). manual - view the manual. preview - run command to preview weblog. publish - run command to publish weblog. tag-entry - tag entry (for '--tag'). update [all|tag|DATE|main|max| - force weblog update (defaults to articles|feeds|tag ] 'all'). update-cache [all|tag|DATE|main|max| - force cache update (defaults to expired|tag ] 'expired'). Options: -b, --blog-dir specify weblog directory. -f, --force force cache update. (synonymous with 'update-cache'). -h,--help show this help message. -i, --interactive <1=on/0=off> toggle interactive mode (for 'add', 'delete', 'preview', 'publish', and 'update'). -v, --verbose <1=on/0=off> toggle verbosity. --conf-file specify alternate configuration file. --desc set text of description (for 'add', 'draft', 'import', and 'make-*'). --data-dir specify weblog's data directory. --meta-file specify meta-file (for 'add'). --title set title (for 'add', 'article', 'draft', 'edit', 'import', and 'make-*'). --author set text of author (for 'add', 'draft', 'import' and 'make-*'). --plugin-dir specify weblog's plugin directory. -q, --query [all|tag|DATE|main|max] - specify a query to run (for 'edit', 'delete', 'list', 'tag-entry', 'update', and 'update-cache'). -c, --tag - specify tag (for 'add', 'delete', 'edit', 'list', 'import', 'update', and 'update-cache'). --text set text of body (for 'add', 'draft', 'import' and 'make-*'). --template specify file to load as template (for 'draft', 'import' and 'make-*'). --template-dir specify weblog's template directory. --var define meta-variable (for 'add', 'draft', 'edit', 'import' and 'make-*'). --set-var set meta-variable (for '--var'). --no-preview disables automatic preview (for 'add'). --no-publish disables automatic publish (for 'add'). --version display version information. More Short Options: -a equivalent of add action. -d deletes entry (works with '-c'). -E equivalent of draft action. -e edits entry (works with '-c'). -l equivalent of list action. -m equivalent of tag-entry action. -u equivalent of update action. --tag,delete,edit,tag-entry accepts multiple ID numbers separated by commas (e.g. 1,2,3). DATE = CCYY-MM-DD, CCYY-MM, CCYY (or range = DATE1,DATE2) note: special queries such as "articles" and "feeds" typically get combined with the update action. More info: URL: http://nanoblogger.sourceforge.net nanoblogger-3.4.2/lang/en/messages.lang000644 000765 000024 00000011632 11063754470 020472 0ustar00kevinwstaff000000 000000 # NanoBlogger English language definitions # Messages # lang/en/messages.lang # main main_badopts="invalid option:" main_panic="Try '`basename $0` --help' for more information." # check_arg checkarg_badarg="option requires an argument!" checkarg_help="Try '`basename $0` --help' for more information." # check_conf checkconf_nobase="base directory doesn't exist! goodbye." checkconf_noblog="no weblog directory specified! goodbye." checkconf_nousrconf="weblog config file doesn't exist! goodbye." checkconf_noblogdir="weblog directory doesn't exist! goodbye." checkconf_nodata="weblog's data directory doesn't exist! goodbye." checkconf_nocache="weblog's cache directory doesn't exist! goodbye." checkconf_noparts="weblog's parts directory doesn't exist! goodbye." checkconf_notemplates="weblog's templates directory doesn't exist! goodbye." # query_db querydb_init="initializing main database ..." querydb_update="updating main database ..." # validate tag id(s) catid_bad="bad id(s)!" checkcatid_invalid="invalid tag id(s):" checkcatid_novalid="must specify valid tag id!" # validate metadata files checkmetavars_novar="missing metavar:" # config_weblog configweblog_nomod="no changes were made! goodbye." # load_template loadtemplate_nofile="template file doesn't exist! goodbye." # make_page makepage_nosource="source file doesn't exist! goodbye." makepage_nooutput="output file not specified." makepage_notemplate="template file doesn't exist! goodbye." # paginate paginate_action="paginating" # build_archives buildarchives_action="generating archives ..." # build_weblog buildweblog_all="updating all weblog files! this may take a while ..." buildweblog_files="generating weblog files ..." buildweblog_main="generating main index page(s) ..." buildweblog_cache="expiring cache data ..." # import_file importfile_nofile="doesn't exist!" # nb_browser nbbrowser_running="running:" nbbrowser_nobrowser="please define another web browser in \$NB_BROWSER or \$BROWSER." # nb_draft nbdraft_asknew="file doesn't exist! create?" # nb_edit nbedit_nofile="file doesn't exist!" nbedit_prompt="press [enter] to continue:" nbedit_failed="failed to write file! goodbye." # add_entry addentry_catinfo="selected tag id(s):" addentry_action="adding new entry ..." # confirm_action confirmaction_ask="are you sure?" # misc. validation errors novalid_entryid="must specify a valid entry id." invalid_entryid="invalid entry id(s):" novalid_entrytime="must specify a valide TIMESTAMP - 'YYYY-MM-DD HH:MM:SS'" invalid_entrytime="invalid entry TIMESTAMP or conflict" # edit_weblog editweblog_onecat="only one tag can be specified when editing a title!" editweblog_title="changing title to:" editweblog_catinfo="selected tag id(s):" editweblog_nomod="no changes were made! goodbye." editweblog_action="processing modified weblog entries ..." editweblog_noaction="no changes were made! goodbye." # delete_weblog deleteweblog_delcat="deleting tag id(s):" deleteweblog_onecat="only one tag can be specified when untagging entries!" deleteweblog_catinfo="selected tag id(s):" deleteweblog_delentry="deleting entry id(s):" # header attributes header_ID="ID" header_Title="Title" header_Category="Tag ID(s)" header_Date="Date" # list_weblog listweblog_nocat="no tags exist yet! goodbye." listweblog_nomatch="nothing matched your query! goodbye." # cat_entry catentry_catfirst="must specify tag before entry!" catentry_catinfo="selected tag id(s):" catentry_tagging="tagging entry id(s):" # add_weblog addweblog_noweblog="no weblog directory specified! goodbye." addweblog_newblog="creating weblog directory" addweblog_nocreate="failed to create weblog directory!" addweblog_copyaction="copying default weblog files ..." addweblog_askconf="would you like to configure the new weblog now?" addweblog_confaction="configuring new weblog ..." addweblog_noconf="weblog not configured! configure with '`basename $0` --blog-dir [blog_dir] configure query all update'" addweblog_newcat="creating new tag" addweblog_titlecat="enter name for the new tag" addweblog_untitled="Untitled" addweblog_madecat="tag database created for" addweblog_author="enter author's name" addweblog_title="enter a title" addweblog_desc="enter a short description" addweblog_editnew="editing new entry ..." addweblog_newarticle="adding new article ..." addweblog_noarticledir="failed to verify articles directory! check ARTICLES_DIR in configuration." addweblog_noarticlesrc="no legitimate article source could be found!" # preview_weblog preview_nocmd="no preview commmand set! goodbye." preview_action="previewing weblog ..." preview_asknow="would you like to preview your weblog now?" # publish_weblog publish_nocmd="no publish command set! goodbye." publish_action="publishing weblog ..." publish_asknow="would you like to publish the weblog now?" # misc. notitle="Untitled" nowritedir="no write permissions for directory! goodbye." samefilename="filename already exists!" filterdate_failed="date filtering failed, using timestamp instead." nanoblogger-3.4.2/lang/en/plugins.lang000644 000765 000024 00000000506 11063754470 020342 0ustar00kevinwstaff000000 000000 # NanoBlogger English language definitions # Plugins # lang/en/plugins.lang # plugins - generic messages plugins_action="generating" plugins_loadaction="loading ..." plugins_entryfilteraction="filtering text:" plugins_articles="articles" plugins_abort="plugin failed! please check plugin for correct settings or disable it" nanoblogger-3.4.2/lang/en/templates.lang000644 000765 000024 00000002572 11063754470 020664 0ustar00kevinwstaff000000 000000 # NanoBlogger English language definitions # Templates # lang/en/templates.lang # weblog entry links and messages template_permlink="Permanent link" template_catlinks="File under:" template_cmtlink="Comments" template_postedby="Posted by" # only here for compat. with early 3.3 rc's permanentlink_title="$template_permlink" categorylinks_title="$template_catlinks" # depecrated catlinks_title here for transitional purposes catlinks_title="$categorylinks_title" commentslink_title="$template_cmtlink" # weblog main messages template_archiveindex="Archive Index" template_category="Categories" template_contact="Contact" template_fortune="Fortune" template_links="Links" template_rentries="Recent entries" template_syndicate="Syndicate" template_syndicate_main="Site" template_status="Weblog status" template_powered="powered by $NB_EDITORNAME, bash, cat, grep, sed, and" articles_nolist="0" categories_nolist="0" # miscellaneous template_archives="Archives" template_main="Main" template_catarchives="Filed under:" template_articles="Articles" # depecrated template_browsecat here for transitional purposes template_browsecat="Browse by category" template_browsedate="Browse by date" template_browseentry="Browse by entry" # weblog status messages template_totalcats="Total categories:" template_totalentries="Total entries:" template_lastentry="Last entry:" template_lastupdated="Last updated:" nanoblogger-3.4.2/docs/nanoblogger.html000644 000765 000024 00000202330 11336333101 020570 0ustar00kevinwstaff000000 000000 NanoBlogger User Manual

NanoBlogger User Manual

by n1xt3r (Kevin Wood)

The official guide to the NanoBlogger weblog engine.

1. Introduction

NanoBlogger is a small weblog engine written in Bash for the command line. It uses common UNIX tools, such as cat, grep and sed to create static HTML content. It's free to use and modify under the GNU General Public License.

Synopsis

 
nb [-b blog_dir] [options] <actions> [<keyword> (variable)]
        

2. Features

  • flexible command line interface
  • highly configurable and script-able :)
  • easy drafting, editing and management of entries
  • archiving by category, year, month, day, and entry
  • pagination
  • permanent and navigational links
  • templates and CSS style sheets for full control over layout
  • placeholders for easy template manipulation
  • support for multiple weblogs
  • support for multiple categories (tags)
  • support for relative and absolute links
  • support for date manipulation of entries
  • Atom syndication (comes with 1.0 format)
  • RSS syndication (comes with RSS 2.0 and 1.0 formats)
  • plugins for calendar, recent entries, weblog status, etc.
  • plugins for text formatting (e.g. line breaks translate to HTML)
  • global (nb.conf) and per-weblog (blog.conf) configuration
  • intelligent update system - only updates relative files
  • simple cache system for improved efficiency
  • independent of java-script and server-side scripting (e.g. PHP)
  • independent of external database (stores data in flat-files)
  • multi-language support
  • multi-platform portability (just Bash and the required commands)

3. Requirements

Programs:

Bash (at least v2.05), cat, cp, cut, dirname, date*, grep, mkdir, mv, rm, sed, sort

* = GNU version recommended, but not required

4. Getting Started

Creating a New Weblog

To create a new weblog (from your shell prompt):

nb --blog-dir [myblog_dir] add weblog
        
where myblog_dir is a nonexistent directory. This will create a new directory, copy the default files over and finally let you edit the weblog's configuration. Multiple weblogs can be created this way.

To set a default weblog directory:

1. edit either nb.conf or $HOME/.nb.conf.
2. set BLOG_DIR to your weblog directory:
        BLOG_DIR="$HOME/public_html/[myblog_dir]"
        

You may also change to the weblog's directory and NanoBlogger will automatically set $BLOG_DIR for you, so you don't have to specify it from the command line.

5. Settings and Configuration

To edit the weblog's configuration invoke:
nb --blog-dir [myblog_dir] configure update all
        
This opens blog.conf from the weblog directory for editing and updates the entire weblog.

Setting the Browser

NB_BROWSER specifies the browser to use and defaults to the standard BROWSER variable. You can specify a different browser to use by setting NB_BROWSER in blog.conf. In Mac OS X, you might choose to set this to "open". If no browser is specified, "lynx" will be used.

Setting the Editor

NB_EDITOR specifies the editor to use and defaults to the standard EDITOR variable. You can specify a different editor to use by setting NB_EDITOR in blog.conf. If no editor is specified, "vi" will be used.

Setting the Date Format for New Entries

DATE_FORMAT specifies the date format to use for new entries. The default is to use the output from the date command. You can also specify the locale to be used for date command (see the variable DATE_LOCALE). You can specify additional command line arguments with DATE_ARGS, useful for specifying time in UTC. Please note that these settings have no effect on previous entries and that if you use UTC, beware of race conditions which can occur because the entry's filename will be out of sync. The solution is to also change DB_DATEARGS to equal DATE_ARGS, so that the two reflect the same date and time. Read the man pages of the date command to see how to customize the format of the date command's output.

Examples:

DATE_FORMAT="%m.%d.%Y %H:%M"
DATE_LOCALE="$LANG"
DATE_ARGS="-u"   

Setting the Timezone

BLOG_TZD sets the timezone for your weblog entries. The default is to set this automatically using, "%z", a non-standard extension of the date command. If the date command on your system doesn't support this, you'll have to set this manually.

Example:

BLOG_TZD="-0:500"
   

Setting the Encoding

BLOG_CHARSET sets the character encoding to be used for your weblog.

Example:

BLOG_CHARSET="iso-8859-1"

WARNING: If you have the Tidy plugin enabled, this setting will be overridden by Tidy. Please, refer to Tidy's documentation for setting the character encoding.

Setting the Mime Type

BLOG_MIMETYPE sets the mime type to be used for your weblog.

Example:

BLOG_MIMETYPE="text/html"
   

Setting the Web Address

BLOG_URL should be set as the full URL to your weblog excluding the index file and any preceding "/".

Example:

BLOG_URL="http://my-site.com/weblog"
   

Setting the Style Sheet

BLOG_CSS sets the style sheet to be used by your weblog. Style sheets are located in the styles directory.

Example:

BLOG_CSS="styles/nb_clean.css"

Setting the Favorite Icon

BLOG_ICON sets the favorite icon to be used by your weblog. Favorite icons are located in the images directory.

Example:

BLOG_ICON="images/favicon.ico"

Toggling display of Directory's Index File in Links

SHOW_INDEXFILE toggles display of a directory index file in links. Defaults to "1", enabled.

Setting the Author's Name

BLOG_AUTHOR can be used to set the author's name, the default is to set the author's name using the common USER variable. Setting BLOG_AUTHOR will override this behavior.

Setting the Default for the "max" Query

MAX_ENTRIES sets the maximum number of entries returned by the "max" query. Defaults to "10".

Setting the Maximum Number of Entries to Display for All Delimited Pages

MAX_PAGE_ENTRIES sets the default maximum number of entries to display for all delimited pages. Defaults to "$MAX_ENTRIES".

MAX_CATPAGE_ENTRIES sets the maximum number of entries to display for each category archive page. Defaults to "$MAX_PAGE_ENTRIES". The category archives will split when the number of entries is greater than $MAX_CATPAGE_ENTRIES.

MAX_MONTHPAGE_ENTRIES sets the maximum number of entries to display for each month archive page. Defaults to "$MAX_PAGE_ENTRIES". The month archives will split when the number of entries is greater than $MAX_MONTHPAGE_ENTRIES.

MAX_MAINPAGE_ENTRIES sets the maximum number of entries to display for each main page. Defaults to "$MAX_PAGE_ENTRIES". The main page will split when $MAX_MAINPAGE_ENTRIES less than the results of MAINPAGE_QUERY.

Setting the Default Query For the Main Page

MAINPAGE_QUERY sets the default query for the main page. Defaults to "max". When combined with MAX_MAINPAGE_ENTRIES, it can be used to paginate the main page.

Setting the Default Text Formatting

ENTRY_FORMAT specifies the default text formatting to use for new entries. Defaults to "raw".

Toggling Creation of Entry Archives

Setting ENTRY_ARCHIVES to equal "1", enables the creation of entry archives and reconfigures the links of the entries to point to their own archive page.

Toggling Creation of Month Archives

Setting MONTH_ARCHIVES to equal "1", enables the creation of month archives.

Toggling Creation of Day Archives

Setting DAY_ARCHIVES to equal "1", enables the creation of day archives and reconfigures the links of the entries to point to their own archive page when $ENTRY_ARCHIVES is not enabled.

Special Archiving Preferences

CATARCH_DATATYPE determines the set of metadata to load for the category archives.

MONTHARCH_DATATYPE determines the set of metadata to load for the month archives.

DAYARCH_DATATYPE determines the set of metadata to load for the day archives.

There's two types of data that can be specified, "ALL" or "NOBODY":

ALL = full entry metadata (slow and bigger cache)
NOBODY = all except entry's BODY metadata (faster and smaller cache)
    

IMPORTANT: Please edit (or create) category_entry.htm, month_entry.htm, and day_entry.htm accordingly.

Setting the Chronological Order

CHRON_ORDER specifies the chronological order of the weblog's archive - 0/1 = normal/reverse. Defaults to "1", reverse order.

WARNING: If you don't use the "configure" action to change this, the databases won't get resorted to reflect the new chronological order.

Setting Actions for Previewing and Publishing

BLOG_PREVIEW_CMD and BLOG_PUBLISH_CMD may both be set to a custom command to run when invoked by their respective actions, preview and publish.

Setting the Cache Preferences

MAX_CACHE_ENTRIES sets the maximum number of entries to store in the cache. Defaults to "$MAX_ENTRIES".

Setting BLOG_CACHEMNG to "0" disables automatic management of the cache. The cache may be managed manually using the update-cache command line action.

Toggling Interactive Mode

BLOG_INTERACTIVE toggles interactive mode for your weblog and has the same effect as the --interactive command line option. The default is "0" for disabled, setting this to "1" will toggle the mode back on.

Toggling the Display of Time Statistics

SHOW_TIMES toggles showing the accumulated user and system times for the build process. This will probably only prove useful if you don't already have the time command on your system. The default is "0" for off, setting this to "1" will toggle it back on.

Changing the File Type

NB_FILETYPE specifies the file type or rather the suffix for the generated files. The default is set to "html".

Changing the Temp Directory

NB_TEMP_DIR specifies the location to temporarily store data. The default is "/tmp", but may be changed on a per-weblog basis to a more private vicinity as an added security precaution on multi-user systems.

Changing the Default Query Mode

QUERY_MODE specifies the default query mode for all weblog operations. Defaults to "all", but can be just about any valid query. See the "query" action for some possible queries.

Links Configuration

ABSOLUTE_LINKS toggles between absolute and relative links. Defaults to "0", relative links.

FRIENDLY_LINKS toggles between friendly and unfriendly links. Friendly links are more text based, where unfriendly links are more numbers based. Defaults to "1", friendly links.

MAX_TITLEWIDTH sets the maximum title width (by number of characters) generated for friendly links.

SHOW_CATLINKS toggles the display of an entry's categories (tags). The default is to display.

PERMALINKS toggles the display of an entry's permanent link. The default is to display permanent links.

Plugins Configuration

PLUGINS_DIR specifies the directory location of global plugins. Global plugins effect all weblogs. The default is set to $NB_BASE_DIR/plugins.

USR_PLUGINSDIR specifies the directory location of the user plugins. User plugins only effect the specified weblog. Global plugins may be overridden by user plugins on an individual basis. For example, if you copy raw.sh into "$BLOG_DIR/plugins/entry/format/", your copy will be used instead of the global raw.sh. The default is set to $BLOG_DIR/plugins.

Global Configuration

NanoBlogger has it's own configuration file, $NB_BASE_DIR/nb.conf that holds settings which effect all weblogs. The global configuration file is read first meaning that settings in the weblog's configuration may override settings in $NB_BASE_DIR/nb.conf. This configuration is also looked for under the file, $HOME/.nb.conf.

Changing the Default Language of NanoBlogger

NB_LANG is a global configuration variable that sets the language definition to load. The default is "en" for English. All language definitions should be referenced by their ISO 639-2 code.

Example for Spanish:

NB_LANG="es"
    

Creating Language Definitions

Creating language definitions is fairly straightforward:

  1. start with the default "en" set.
  2. redefine all the variables to their equivalent translation in the target language.
  3. save the translated set to a sub-directory named after it's ISO 639-2 alpha-3 or alpha-2 code under the "lang" directory.

6. Managing Entries and Tags (Categories)

Commands to manage entries and tags.

Managing Entries

Entry ID's

The latest entry added, will always have an ID of "1", entry's added before that will have ID's of higher values. An entry may have a different ID for each tag view. When modifying entries based on it's tag, ID's for both tag and entry must be specified.

Drafting Entries

Creating a new draft:

nb [-b blog_dir] draft somefile.txt
    

Importing the draft as a new entry:

nb [-b blog_dir] import entry somefile.txt
    

Creating Entries

Adding new entry:

nb [-b blog_dir] add entry
        
Tagging new entry:
nb [-b blog_dir] --tag <ID> add entry

Setting title and author for new entry:
nb [-b blog_dir] --title "New Entry" --author [entry_author] add entry
        
Setting title, author, and body for new entry:
nb [-b blog_dir] --title "New Entry" --author [entry_author] --text "This is my message." add entry
        
Importing new entry from file:
nb [-b blog_dir] import entry somefile.txt

Listing Entries

Listing entries:

nb [-b blog_dir] list [<query>]

Listing entries by tag:
nb [-b blog_dir] list tag <ID> 
        

Editing Entries

Editing entry:

nb [-b blog_dir] edit entry <ID>
        
Editing entry by tag:
nb [-b blog_dir] --tag <ID> edit entry <ID>
        
Editing multiple entries:
nb [-b blog_dir] edit entry 1,2,3
        

Assigning Entries To Tags

Assigning tag to entry:

nb [-b blog_dir] --tag <ID> tag-entry <ID>
        
Assigning multiple tags to entry:
nb [-b blog_dir] --tag 1,2,3 tag-entry <ID>
        
Assigning multiple entries to tag:
nb [-b blog_dir] --tag <ID> tag-entry 1,2,3
        

Deleting Entries

Permanently delete entry:

nb [-b blog_dir] delete entry <ID>
        
Permanently delete multiple entries:
nb [-b blog_dir] delete entry 1,2,3
        
Un-tag entry:

1.) find the entry ID from the listing:

nb [-b blog_dir] --tag <ID> list

2.) remove the entry using the entry ID we found in the first step:

nb [-b blog_dir] --tag <ID> delete entry <ID>
        

Changing Entry's Date

Specifying new entry's date using the TIMESTAMP meta-tag:

nb [-b blog_dir] --var TIMESTAMP --set-var "CCYY-MM-DD HH:MM:SS" add entry
    
Changing old entry's date:
nb [-b blog_dir] --var TIMESTAMP --set-var "CCYY-MM-DD HH:MM:SS" edit entry <ID>
     
Manually changing entry's date:
1. nb [-b blog_dir] edit entry <ID>
2. TIMESTAMP: CCYY-MM-DD HH:MM:SS
     
The date command must support the "-d" option for the date to follow the format set by "$DATE_FORMAT".

Managing Tags

Also known as categories.

Tag ID's

Tag ID's count up from 1. A tag's ID remains constant until that tag is deleted. Deleting a tag will free up that tag's ID for use by a new tag upon creation.

Tag Commands

Creating a new tag:

nb [-b blog_dir] add tag
        
Setting the title for a new tag:
nb [-b blog_dir] --title examples add tag
        
Listing available tags:
nb [-b blog_dir] list tags
        
Tagging existing entries:
nb [-b blog_dir] --tag <ID> tag-entry <ID>

Editing a tag's title:
nb [-b blog_dir] --title example edit tag <ID>
        
Deleting a tag:
nb [-b blog_dir] delete tag <ID>
        

Advanced Management

Use the "--query" option to manipulate the list of entries which to operate from. First review your query by combining the "--query" with the "list" action to see which entry ID(s) matched your query. Then operate from that same query by combining the "--query" option with one of the "edit", "delete", "tag-entry", or "update" actions. Using the entry ID(s) from your last query accordingly.

Editing entries by query:

nb [-b blog_dir] --query <all,CCYY-MM-DD,max> list
nb [-b blog_dir] --query <all,CCYY-MM-DD,max> edit entry <ID>
Deleting entries by query:
nb [-b blog_dir] --query <all,CCYY-MM-DD,max> list
nb [-b blog_dir] --query <all,CCYY-MM-DD,max> delete entry <ID>
Editing entries by tag and query:
nb [-b blog_dir] --tag <ID> --query <all,CCYY-MM-DD,max> list
nb [-b blog_dir] --tag <ID> --query <all,CCYY-MM-DD,max> edit entry <ID>

7. Templates

Templates are located in the weblog's sub-directory, templates.

Special Template Characters

IMPORTANT: Escaping these characters is necessary to prevent them from being interpreted by the shell.

Special characters that, when placed in templates, are interpreted by the shell if not escaped:
characters description notes
$ dollar sign prefix backslash to escape, e.g. "\$"
` back quote form of command substitution, prefix backslash to escape, e.g. "\`"
$( dollar sign and left parenthesis form of command substitution, prefix backslash to escape, e.g. "\$("

Default Templates

The weblog's appearance is controlled by the following templates:
templates description
archive_index.htm controls structure of the archive index page
category_archive.htm controls structure of the category pages
day_archive.htm controls structure of the day archive pages
main_index.htm controls structure of the weblog's main page
main_links.htm* contains user defined links
makepage.htm default template used by make-page action
month_archive.htm controls structure of the month archive pages
permalink.htm controls structure of the entries' archive pages
entry.htm controls structure of the entry's content for most archives
permalink_entry.htm controls structure of the entry's content for individual entry archives
weblog_status.htm controls structure of weblog status
year_archive.htm controls structure of year archive pages
entry.metadata controls the format of the entry's meta-file
file.metadata controls the format of a meta-file

Special Templates

The weblog's appearance may be further controlled by the following templates:
templates description
category_entry.htm controls structure and content of the category entries
month_entry.htm controls the structure and content of the month entries
day_entry.htm controls the structure and content of the day entries

8. Articles and the Articles Plugin

Articles are independent from the main weblog's archives and they provide a fast and easy way to organize and create additional content for the weblog. Management is almost entirely accomplished through your file manager (or command line). The articles are simply created from meta-files found in the articles directory. Refreshing articles occurs on the next update of the weblog or upon a forced update, whichever occurs first. The generation of the articles listing and content depends on the articles plugin. For more information about the articles plugin, please refer to "*articles_meta.sh" in About Plugins.

Configuring Articles

Setting the Articles Directory

ARTICLES_DIR sets the articles directory for your weblog. Defaults to "articles". Multiple articles directories may be specified.

Example:

ARTICLES_DIR="articles articles/misc"

Setting the Default Text Formatting for Articles

ARTICLES_FORMAT sets the default text formatting for new articles. Defaults to "raw".

Setting the Default Suffix for Articles

ARTICLES_SUFFIX sets the suffix to include as article under the articles directory. Defaults to ".txt".

Setting the Default Template for Articles

ARTICLES_TEMPLATE sets the default template to use for new articles. Defaults to "[blog_dir/]templates/makepage.htm".

Adding New Articles

Creating new articles is made easy with help from the 'add article' command:

nb [--title 'Example Article'] add article

Importing new article (into existing articles sub-directory):

nb import article [blog_dir/]articles/misc/example.txt

Manually Refreshing Articles

Manually refreshing articles listing and content:

nb update articles

9. About Plugins

Plugins Framework

Regular Plugins: plugins

Regular plugins are initialized unconditionally after a requested update.

Archive Plugins: plugins/archive

Archive plugins are initialized when the archives are to be updated.

Category Archive Plugins: plugins/archive/category

Category Archive plugins are initialized for each category archive that is to be updated.

Day Archive Plugins: plugins/archive/day

Day Archive plugins are initialized for each day archive that is to be updated.

Month Archive Plugins: plugins/archive/month

Month Archive plugins are initialized for each month archive that is to be updated.

Year Archive Plugins: plugins/archive/year

Year Archive plugins are initialized for each year archive that is to be updated.

Entry Plugins: plugins/entry

Entry plugins are initialized unconditionally for each entry that is to be updated.

Entry Modify Plugins: plugins/entry/mod

Entry Modify plugins are initialized for each entry that is modified.

Entry Formatting Plugins: plugins/entry/format

Entry Formatting plugins are initialized for each modified entry based on the FORMAT meta-tag field. More than one format may be specified using space or commas as a separator, but special care should be taken in the order they get specified.

Page Plugins: plugins/page

Page plugins are initialized unconditionally before each page that is to be updated.

Page Formatting Plugins: plugins/page/format

Page Formatting plugins are initialized for each page that is to be updated based on the FORMAT meta-tag field. More than one format may be specified using space or commas as a separator, but special care should be taken in the order they get specified.

Make Page Plugins: plugins/makepage

Make Page plugins are initialized after each page that is to be updated.

Post Plugins: plugins/post

Post plugins are initialized unconditionally for post-weblog related tasks.

Note: Most plugins will operate on their own conditions once they've been initialized, in other words, no longer unconditionally.

Default Plugins

Default plugins (most are enabled by default):
plugins description variables targets notes
archive/day/cal2daytitle.sh creates a fancier title for the day archives CAL_CMD, CAL_ARGS, DATE_LOCALE $NB_ArchiveTitle requires the cal command
archive/month/month_calendar.sh generates a calendar with links for each active day CAL_CMD, CAL_ARGS, DATE_LOCALE $NB_MonthlyCalendar requires the cal command
archives/year/year_index.sh generates year archives none $ARCHIVES_DIR/$yearn/index.$NB_FILETYPE requires makepage.htm template
articles_meta.sh* generates articles from meta-files in the "articles" directory ARTICLES_DIR, ARTICLES_FORMAT $NB_ArticleLinks requires makepage.htm template, plugin should be ordered so that it's loaded last
atom.sh adds atom feed BLOG_FEED_ITEMS, ATOM_ITEMS, ATOM_CATFEEDS, ATOM_FEED_LANG $NB_AtomVer, $NB_AtomFile, index-atom.$NB_SYND_FILETYPE none
calendar.sh generates a calendar with links for each active day CAL_CMD, CAL_ARGS, DATE_LOCALE $NB_Calendar requires cal
entry/category_links.sh generates category links none $NB_EntryCategories none
entry/excerpt.sh* creates excerpt from entry's text none $NB_EntryExcerpt ends after first detected double line break (blank line)
entry/format/autotag-br.sh converts blank lines to HTML paragraph breaks none $NB_MetaBody, $NB_EntryBody FORMAT: autotag-br
entry/format/markdown.sh uses markdown to handle formatting MARKDOWN_CMD, MARKDOWN_OPTS $NB_MetaBody, $NB_EntryBody FORMAT: markdown
entry/mod/base_url.sh helps set relative links %base_url% $NB_EntryBody example: <img src="%base_url%images/pic.png" />
entry/mod/moods.sh converts mood variables into smiley icons MOODS_URL $NB_EntryBody copy moods directory to weblog's directory
fortune.sh generates random quotes FORTUNE_CMD, FORTUNE_FILE $NB_Fortune requires fortune
makepage/tidy.sh validates HTML/XML code TIDY_CMD, TIDY_HTML_ARGS, TIDY_XML_ARGS $NB_Tidy, $BLOG_DIR/tidy.log requires HTML Tidy, overrides $BLOG_CHARSET
mymood.sh* adds ability to display your mood MOODS_URL $NB_MyMood copy moods directory to weblog's directory
page/feed_links.sh generates alt links for feeds none $NB_AtomAltLink, $NB_RSS2AltLink, $NB_RSSAltLink requires one of atom.sh, rss.sh, or rss2.sh plugins
page/page_links.sh regenerates links for inclusion on other pages none $NB_MainLinks, $NB_RecentEntries, $NB_CategoryLinks, $NB_MonthLinks, etc. requires one of weblog_links.sh or recent_entries.sh plugins
page/format/autotag-br.sh converts blank lines to HTML paragraph breaks none $NB_MetaBody, $NB_EntryBody FORMAT: autotag-br
page/format/markdown.sh uses markdown to handle formatting MARKDOWN_CMD, MARKDOWN_OPTS $NB_MetaBody, $NB_EntryBody FORMAT: markdown
page/format/moods.sh converts mood variables into smiley icons MOODS_URL $NB_MetaBody, $NB_EntryBody may combine with with others e.g. "FORMAT: moods, markdown"
recent_entries.sh generates lists of recent and old entries RECENTLIST_ENTRIES, RECENTLIST_OFFSET, RECENTLIST_MODE $NB_RecentEntries, $NB_OlderEntries none
rss2.sh adds rss 2.0 feeds BLOG_FEED_ITEMS, RSS2_ITEMS, RSS2_CATFEEDS, BLOG_FEED_LANG $NB_RSS2File, index-rss.$NB_SYND_FILETYPE none
rss.sh adds rss 1.0 feeds BLOG_FEED_ITEMS, RSS_ITEMS, RSS_CATFEEDS, BLOG_FEED_LANG $NB_RSSFile, index.$NB_SYND_FILETYPE none
weblog_links.sh generates some useful links ALL_YEARLINKS, MAX_YEARLINKS, ALL_MONTHLINKS, MAX_MONTHLINKS $NB_MainLinks, $NB_MonthLinks, $NB_CategoryLinks requires main_links.htm template
weblog_status.sh generates some statistics none $NB_BlogStatus requires weblog_status.htm template

* = actual name may vary.

To disable an individual plugin, rename the plugin's extension from ".sh" to ".off".

10. Configuring Plugins

Settings for plugins are stored and set in your weblog's blog.conf.

Configuring Syndication Plugins

Syndicating your weblog is achieved through NanoBlogger's plugins. Please note, a complete and Internet accessible URL is required for proper syndication. This can be set using BLOG_FEED_URL. It is also wise to ensure a correct timezone setting for your syndication feeds. For this, please refer to BLOG_TZD in Settings and Configuration.

Setting the Web Address

BLOG_FEED_URL sets the URL for syndication feeds. Defaults to "$BLOG_URL", only if it's already set.

Example:

BLOG_FEED_URL="http://www.example.com/johndoe/weblog"

Setting the Time Zone

BLOG_FEED_TZD sets the timezone used for syndication feeds. Defaults to "$BLOG_TZD".

Setting the Lanuage

BLOG_FEED_LANG sets the language used in your syndication feeds.

Example:

BLOG_FEED_LANG="en-us"

ATOM_FEED_LANG sets the language for Atom syndication feeds.

Example:

ATOM_FEED_LANG="en"

NOTE: The language code for Atom syndication feeds is different from the RSS standard.

Setting the Maximum Number of Items to Syndicate

BLOG_FEED_ITEMS sets the maximum number of entries to include in your syndication feeds, independent of $MAX_ENTRIES. Defaults to "10". For exporting purposes you may want to set this to "-1" to include all the existing weblog's entries.

Example:

BLOG_FEED_ITEMS="10"

Support for Style Sheets

BLOG_FEED_CSS sets the style sheet used for your syndication feeds (path should be relative).

Example:

BLOG_FEED_CSS="styles/feed.css"

Support for Icons & Logos

BLOG_FEED_ICON sets an icon for your syndication feeds (path should be relative).

Example:

BLOG_FEED_ICON="images/feedicon.png"

BLOG_FEED_LOGO sets a logo for your syndication feeds (path should be relative).

Example:

BLOG_FEED_LOGO="images/feedlogo.png"

NOTE: In the RSS 2.0 syndication plugin, the logo will be used when the icon is not set.

Support for Syndicated Categories

There are three settings that control category syndication feeds:

  1. CATEGORY_FEEDS master toggle for category syndication. Defaults to "0" - disabled.
  2. ATOM_CATFEEDS toggles Atom based syndication for categories. Defaults to "0" - disabled.
  3. RSS2_CATFEEDS toggles RSS 2.0 based syndication for categories. Defaults to "0" - disabled.

Support for Creating Podcasts

There's a special meta-tag called, ENCLOSURE which is used to set an entry's enclosure data for each entry. The ENCLOSURE meta-tag should contain two different sets of data separated by a single space. The local media file and the media type (e.g. audio/mpeg).

Example:

ENCLOSURE: mp3s/mypodcast.mp3 audio/mpeg

The media file should be from a relative path which can be found from within $BLOG_DIR. The system command "du -b" is required to acquire the media file's length to complete the enclosure data. The "du" command should be included on most systems where Bash is supported, but there's no guarantee the syntax will be the same. Auto-detecting the media type is not supported, it must be determined and set manually. Enclosures are supported for both the Atom and RSS2 syndication plugins.

Syntax Checking & Reformatting

The Tidy plugin provides syntax checking and reformatting. These kind of tools can be both your friend and your enemy, meaning they can sometimes hide (fix) your mistakes too well. A log is kept in your weblog's directory, so you can review any errors or changes recorded by Tidy.

There are two Tidy configuration variables. One for HTML and one for XML (syndication plugins). As noted in Settings and Configuration, Tidy has a tendency to rewrite whatever you set in $BLOG_CHARSET. So beware.

TIDY_HTML_ARGS sets the command arguments for the tidy command.

TIDY_XML_ARGS set the command arguments for the tidy command when verifying XML of syndication feeds.

Examples:

TIDY_HTML_ARGS="-asxhtml -n -utf8"
TIDY_XML_ARGS="-xml -n -utf8 -wrap 0"

More advanced configuration including customizations can be achieved through user plugins.

11. Writing Plugins

Tools for Developing Plugins

Plugins typically work by creating placeholders for the templates, but are in no way limited to creating placeholders. Placeholders allow for a great deal of control in how the plugins output is placed in the template. Some plugins may require you to identify it's unique placeholder/destination and manually add it to your templates.

To write a plugin, you should begin by creating a text file with the ".sh" suffix. plugins are basically shell scripts that get loaded (sourced in shell terms) depending on where the plugin is located in the plugins directory or one of the plugin sub-directories. It may be a good idea to look at a simple plugin, such as fortune.sh for an idea on how a plugin works. When the new plugin is saved, it needs to have the appropriate read permissions, so it can be loaded by NanoBlogger. Executable permissions are not necessary for plugins.

The following is a collection of tools that might be useful when developing your own plugins.

Plugin API

API for writing plugins.
command description variables and switches targets notes
die exits with error message $@ stdout returns exit status 1
nb_browser sensible-browser-like utility for launching browser $NB_BROWSER, $BROWSER, $1 stdout parses $BROWSER with ":" separator
nb_edit simple wrapper to editor $NB_EDITOR, $EDITOR, $1, $2, -p = force prompt (pause) stdout if $2 is null, then $1 assumed to be file
nb_eval silent wrapper to eval $? $DEVNULL returns exit status 0 upon success
nb_print prints a file line by line filename=$1, number of lines=$2 (blank for all) stdout use instead of "sed 1q"
nb_msg preferred method of verbosity $@ stdout use instead of echo when appropriate
confirm_action ask user to confirm action none stdout can be used with $BLOG_INTERACTIVE
chg_suffix changes a file's suffix filename=$1, suffix=$2 file can specify $NB_FILETYPE, $NB_SYND_FILETYPE as suffix
query_db queries database db_query=$1, db_catquery=$2, db_setlimit=$3 db_limit=$4, db_offset=$5 $DB_RESULTS example (retrieves entries 1 through 10): "query_db all nocat limit 10 1"
lookup_id lookup id of item matched from master database $1, $2 stdout example: lookup_id 2005-12-14T00_00_00.$NB_DATATYPE "$MASTER_DB_RESULTS"
translit_text transliterates text into a suitable form for web links $1 stdout none
set_baseurl helps in setting relative links node_var=$1, base_dir=$2 $BASE_URL, $ARCHIVES_PATH should only specify one, of node_var or base_dir, at a time
set_catlink sets link and file for given category $1 $category_file, $category_link category should be of the form, cat_N.$NB_DBTYPE
set_daylink sets link and file for given day $1 $day_file, $day_link day should be of the form CCYY-MM-DD
set_monthlink sets link and file for given month $1 $month_file, $month_link month should be of the form CCYY-MM
set_entryid sets anchor/id for given entry $1 stdout entry should be of the form CCYY-MM-DDTHH_MM_SS.$NB_DATATYPE
set_entrylink sets link and file for given entry $1 $entry_dir, $permalink_file, $NB_EntryPermalink entry should be of the form CCYY-MM-DDTHH_MM_SS.$NB_DATATYPE
update_cache compiles list or removes cache entries cache_update=$1, cache_def=$2, CACHEUPDATE_LIST=$3 $CACHE_LIST commonly used to expire cached data
load_template loads template from file TEMPLATE_FILE=$1 $TEMPLATE_DATA never load template data more than once, make_page calls load_template
write_template writes template data to stdout $TEMPLATE_DATA stdout example: write_template > "$OUTFILE"
load_metadata loads metadata from (entry) file METADATA_TYPE=$1, $METADATA_FILE=$2 depends on $METADATA_TYPE metadata type can be ALL, NOBODY, BODY, TITLE, AUTHOR, DATE, DESC, FORMAT
write_metadata writes metadata to file MVAR=$1, METADATA=$2, META_FILE=$3 $META_FILE example: "write_metadata UPDATED "`date`" $meta-file"
read_metadata extracts metadata from (entry) file MVAR=$1, META_FILE=$2 $METADATA see plugin recent_entries.sh for a good example
write_var create/modify user metedata field WRITE_MVAR=$1, WRITE_MVARVALUE=$2, WRITEMETAVAR_FILE=$3 $WRITEMETAVAR_FILE example: write_var MODTIME "$(date)" $meta-file
loop_archive loops through archives and executes instructions by years or months looparch_list=$1, looparch_type=$2, looparch_exec=$3 determined by $looparch_exec example: "query_db max; loop_archive "$DB_RESULTS" months make_monthlink"
load_entry loads entry data for templates ENTRY_FILE=$1, ENTRY_DATATYPE=$2, ENTRY_CACHETYPE=$3 $NB_EntryTitle, $NB_EntryBody, ... see plugin atom.sh for a good example
make_page creates weblog page from text file MKPAGE_SRCFILE=$1, MKPAGE_TMPLFILE=$2, MKPAGE_OUTFILE=$3 $MKPAGE_CONTENT, $NB_MetaBody see plugin articles_text.sh for a good example
weblog_page creates weblog page from meta-file BLOGPAGE_SRCFILE=$1, BLOGPAGE_TEMPLATE=$2, $BLOGPAGE_OUTFILE=$3 $MKPAGE_CONTENT, $NB_MetaBody see plugin articles_meta.sh for good example

12. Publishing

Setting the Publish Command

The BLOG_PUBLISH_CMD variable allows you to set a command to publish your weblog. This can be as simple as an FTP command to upload files or a more complex set of tasks via a script.

Publishing Remotely

FTP, SSH (scp, sftp, etc.), RSYNC or WebDAV, are all methods that can be used to publish the weblog.

example: automating publishing with ftp and .netrc.

blog.conf:
BLOG_PUBLISH_CMD="ftp example.weblog.com"
 
.netrc:
machine example.weblog.com login foo password
RIGHT!
macdef init
passive on
prompt off
lcd ~/public_html/blog
mput *.*
cd archives
lcd archives
mput *
 

Publishing Locally

If you choose to publish locally, you'll probably want to disable the publish command. To do this you can set BLOG_PUBLISH_CMD to null. e.g. BLOG_PUBLISH_CMD=""

13. Adding Support for Comments

Comment services and add-on's: NanoBlogger Comments, CGIComment, blogkomm[1], JS-Kit[2], and Haloscan.com[3].

Choose one and follow the included install instructions.

14. Importing Entries

In order to import entries, data must first be converted to the NanoBlogger format.

Format of an Entry

An entry file name is of the format:

CCYY-MM-DDTHH_MM_SS.txt
        
So a typical entry's file name would look something like this:
2004-06-25T22_24_37.txt
        

The format of an entry is made up of meta-tags . Most of the meta-tags are of the format VAR: VALUE, then a carriage return that separates one meta-tag from the next. The order of the meta-tags are insignificant. The BODY variable is special and needs to be terminated by the END----- marker. By default the content of the BODY variable must contain valid HTML with all entities properly escaped.

Example of an entry's format:
TITLE: A New Entry
AUTHOR: foo
DATE: January 30 2004, 12:00 PM
DESC: keywords or a short, one line summary
FORMAT: raw
-----
BODY:
<p>This is my new entry ...</p>
END-----
        

Converting Entries

Before entries can be imported they must be converted to the correct format.

Steps to converting entries:

1. Convert each entry so they each contain the following meta-tags: TITLE, AUTHOR, DATE, DESC, FORMAT, BODY
2. The BODY meta-tag must be terminated by "END-----".
3. Rename each entry's file name to it's corresponding date and time.
        

If there's multiple entries it may be a good idea to automate all this with a script.

Updating the Weblog's Data Directory

The imported entries should be copied into the data directory of your weblog.
Update the weblog with the new entries:

nb [-b blog_dir] --force update all
        

14. Tips and Tricks

Useful Editor's Commands

Create a new meta-file:
nb [-b blogdir] make-file somefile.txt
Import the meta-file as a new weblog entry:
nb [-b blogdir] import entry somefile.txt
or export the meta-file as a new weblog page:
nb [-b blogdir] make-page somefile.txt somefile.html
Please note that these tasks are easier when the editor supports a sub-shell or when you can suspend your editor from the active shell (assuming there is one).

Writing Meta Tags on the Fly

Meta-tags are simply the tags that pertain to a meta-file. For instance, the text formatting can be manipulated from the command line.

nb [-b blogdir] --var FORMAT --set-var "markdown" make-page somefile.txt somefile.html
    

Currently, only one meta-tag may be specified at a time.

Set a Default Weblog Directory

By default you have to specify the weblog directory, but by setting BLOG_DIR, you won't have to. Edit nb.conf or $HOME/.nb.conf:

BLOG_DIR="/path/to/weblog"
    

Disabling Plugins

You may wish to disable the global plugins or all plugins.

To disable global plugins edit blog.conf and change PLUGINS_DIR to a preexisting directory:

PLUGINS_DIR="$BLOG_DIR/plugins"
    

To disable all plugins, including user's, edit blog.conf and change PLUGINS_DIR and USR_PLUGINSDIR to a preexisting (empty) directory:

PLUGINS_DIR="$BLOG_DIR/no-plugins"
USR_PLUGINSDIR="$BLOG_DIR/no-plugins"

As noted previously, plugins can be disabled on an individual basis by changing their suffix to something other than ".sh".

Adding Shell Scripting to Your Templates

It's possible to use command substitution in your templates, using one of the following forms:

        $(command)
or
        `command`
                

Add an Introduction to Your Weblog

Create a text file in your weblog directory called, "intro.txt". Edit the text file the way you like, then add the following to the main template:

$(< "$BLOG_DIR/intro.txt")
        

Integrating Parts of Your Weblog Into an Existing Web Site

Many parts of the weblog are stored and built in the parts directory. Say you already have a web site full of your own custom server-side scripts/includes, but you'd like to add a news section. This is where the "parts/index.html" file comes in. It contains all the most recent entries, so adding a news/diary/blog section is just a matter of adding the code to include "parts/index.html" into the page.

Other clever uses include combining NanoBlogger's static output with some PHP or Perl. For example, suppose you like to have some of the side links, such as recent entries. Using PHP, set your NB_FILETYPE to "php" and modify the appropriate templates to include the PHP code that extracts the data from the parts directory. One of the main advantages to this is not having to rebuild the entire weblog's archives, just to keep the links current.

Embedding Other Variables in the Templates

Any characters that are similar to the shell's variable or command substitution characters, will have to be escaped before they will work from the templates.

Example using variables in the PHP code:

<?php
\$VAR = array ();
echo "\\\$VAR=\$VAR";
php?>
     

16. Credits

Thanks to Adrien "ze" Urban, Paul Drain, Pavel Janik, and O.R.Senthil Kumaran for all the contributions and suggestions. Thanks to Bowie J. Poag, author of MicroBlogger, for the inspiration of this project. Special acknowledgment goes to Ted Walther's Diary[4], which inspired Bowie to create MicroBlogger. Finally, thanks to everyone who's ever contributed a patch or feature request - see the ChangeLog.

1. http://blogkomm.com
2. http://js-kit.com
3. http://www.haloscan.com
4. http://reactor-core.org/~djw/diary/

nanoblogger-3.4.2/default/articles/000755 000765 000024 00000000000 11336333423 017716 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/blog.conf000644 000765 000024 00000020625 11336136365 017715 0ustar00kevinwstaff000000 000000 # NanoBlogger Weblog Config File - blog.conf # Default configuration with sensible presets # Last modified: 2010-02-14T22:01:41-05:00 # --- Main Preferences --- # # set default editor for your weblog (defaults to $EDITOR). NB_EDITOR="$EDITOR" # set default browser for previewing your weblog (defaults to $BROWSER) NB_BROWSER="$BROWSER" # maximum number of entries to query when query equals "max". MAX_ENTRIES="10" # date format used for a new entry (used by the "date" command). # e.g. DATE_FORMAT="%Y-%m-%d %H:%M:%S" DATE_FORMAT="" # Date's locale (language) to display in (e.g. DATE_LOCALE="$LANG") # NOTE: intentionally setting this as null causes it to be auto-filled # with the default values. DATE_LOCALE="" # date command arguments (see date's man page). DATE_ARGS="" # set the full URL to your weblog (required for absolute links). # e.g. BLOG_URL="http://weblog.user/~foo" ("/" gets appended automatically) BLOG_URL="" # stylesheet used for your weblog (should always be relative link). BLOG_CSS="styles/nb_default.css" # shortcut icon for your weblog (should always be relative link). BLOG_ICON="images/favicon.ico" # action to perform on links to entries (e.g. run a server-side script) # NOTE: must be activated in templates. # e.g. for here (relative path): BLOG_URL_ACTION="cgi-bin/cgicomment.pl?article=" # e.g. for templates: ${BASE_URL}$BLOG_URL_ACTION BLOG_URL_ACTION="" # set the Language (character encoding) used for your weblog. BLOG_CHARSET="utf-8" # set the mime type used for your weblog # e.g. BLOG_MIMETYPE="text/html" BLOG_MIMETYPE="text/html" # set the timezone your weblog (should follow W3CDTF date format). # if your system supports "date +%z", you can leave this blank. # e.g. BLOG_TZD="-05:00" BLOG_TZD="" # title of your weblog. BLOG_TITLE="My Weblog" # description of your weblog. BLOG_DESCRIPTION="news, diary, journal, whatever" # default author of your weblog (defaults to $USER). BLOG_AUTHOR="" # contact information for your weblog. # e.g. BLOG_CONTACT=''$BLOG_AUTHOR'' BLOG_CONTACT="" # --- Misc. Preferences --- # # command to run when previewing your weblog. # used by the option and prompt for previewing (when set). BLOG_PREVIEW_CMD="nb_browser $BLOG_DIR/index.html" # command to run when publishing your weblog to a remote site. # used by the option and prompt for publishing (when set). BLOG_PUBLISH_CMD="" # enable Interactive mode (classic behavior) - 0/1 = off/on. BLOG_INTERACTIVE="0" # show weblog build time statistics SHOW_TIMES="0" # set the query mode used for listing and managing entries. # defaults to max, but may be just about any valid query. #QUERY_MODE="max" # --- Link Preferences --- # # toggles display of directory index file in links (strongly suggested # for local preview) - 0/1 = off/on SHOW_INDEXFILE="1" # show permanent links for each entry - 0/1 = off/on. SHOW_PERMALINKS="1" # show category links for each entry - 0/1 = off/on. SHOW_CATLINKS="1" # toggles between friendly and unfriendly (non-title based) links # 1/0 = friendly/unfriendly. FRIENDLY_LINKS="1" # maximum title width (by characters) generated for "friendly" links. # (defaults to 150) MAX_TITLEWIDTH="150" # enable absolute links (full path to domain/$BLOG_URL) - 0/1 = off/on. # defaults to relative links, "0" # NOTE: depends on $BLOG_URL in order to work properly. ABSOLUTE_LINKS="0" # --- Archive Preferences --- # # maximum number of entries to display for multiple pages MAX_PAGE_ENTRIES="30" # maximum number of entries to display for each category page #MAX_CATPAGE_ENTRIES="$MAX_PAGE_ENTRIES" # maximum number of entries to display for each month page # NOTE: breaks target links unless day archives enabled #MAX_MONTHPAGE_ENTRIES="$MAX_PAGE_ENTRIES" # maximum number of entries to display for each main page #MAX_MAINPAGE_ENTRIES="$MAX_PAGE_ENTRIES" # sets the query for the main page, defaults to "max". # NOTE: you can paginate the main page by setting this to "all" or # any query where the results are > MAX_MAINPAGE_ENTRIES. #MAINPAGE_QUERY="max" # build individual archives of each entry - 0/1 = off/on. ENTRY_ARCHIVES="1" # build month archives - 0/1 = off/on. MONTH_ARCHIVES="1" # build day archives (depends on MONTH_ARCHIVES) - 0/1 = off/on. DAY_ARCHIVES="0" # specify data to load for different archives - ALL or TITLE. # ALL = full entry metadata (slow and bigger cache) # TITLE = title metadata only (faster and smaller cache) # # modify/create the category_entry.htm template accordingly. CATARCH_DATATYPE="TITLE" # modify/create month_entry.htm template accordingly. MONTHARCH_DATATYPE="ALL" # modify/create day_entry.htm template accordingly. DAYARCH_DATATYPE="ALL" # chronological order - 0/1 = normal/reverse. CHRON_ORDER="1" # set the file type for your weblog, defaults to "html". # NOTE: changing this will require a complete update of the weblog. #NB_FILETYPE="html" # --- Plugin Preferences --- # # plugins directory, defaults to $NB_BASE_DIR/plugins. # NOTE: intentionally setting this as null causes it to be auto-filled # with the default values. PLUGINS_DIR="" # user plugins directory, defaults to $BLOG_DIR/plugins. # NOTE: intentionally setting this as null causes it to be auto-filled # with the default values. USR_PLUGINSDIR="" # toggle excerpting of entries ENTRY_EXCERPTS="1" # 1/0 = on/off # default entry text formatting (name of the text formatting plugin(s)). # e.g. plugins/entry/format/autobr.sh = autobr ENTRY_FORMAT="raw" # default page text formatting (name of the text formatting plugin(s)). # e.g. markdown = plugins/page/format/markdown.sh #PAGE_FORMAT="raw" # defaults to raw # maximum links to yearly archives (-1 = all) MAX_YEARLINKS="12" # defaults to 12 # maximum links to monthly archives (-1 = all) MAX_MONTHLINKS="12" # defaults to 12 # calendar plugin configuration #CAL_CMD="cal" CAL_ARGS="" # tidy plugin configuration #TIDY_CMD="tidy" TIDY_HTML_ARGS="-asxhtml -n -utf8" # used when verifying syndication feeds TIDY_XML_ARGS="-xml -n -utf8 -wrap 0" # markdown plugin configuration #MARKDOWN_CMD="python -m markdown" #MARKDOWN_OPTS="/dev/stdin" # fortune plugin configuration #FORTUNE_CMD="" #FORTUNE_FILE="" # --- Plugin: Syndication Preferences --- # # set the required URL for your weblog feeds. # e.g. BLOG_FEED_URL="http://weblog.user/~foo" ("/" gets appended automatically) BLOG_FEED_URL="http://localhost/please/edit/me" # set the timezone used for weblog feeds, defaults to $BLOG_TZD. BLOG_FEED_TZD="$BLOG_TZD" # set the language for your RSS feeds. BLOG_FEED_LANG="en-us" # set the language for your Atom feeds. # NOTE: requires different language code than RSS. ATOM_FEED_LANG="en" # set stylesheet for weblog feeds (path should be relative # e.g. styles/feed.css). BLOG_FEED_CSS="styles/feed.css" # set a logo for weblog feeds. (path should be relative # e.g. images/feedlogo.png). BLOG_FEED_LOGO="" # set an icon for weblog feeds (path should be relative # e.g. images/feedicon.png). # NOTE: Only RSS 2.0 seems to support this BLOG_FEED_ICON="" # enable/disable all category feeds - 0/1 = off/on. CATEGORY_FEEDS="0" # enable/disable* Atom category feeds - 0/1 = off/on. ATOM_CATFEEDS="0" # enable/disable* RSS 2.0 category feeds - 0/1 = off/on. RSS2_CATFEEDS="0" # enable/disable* RSS 1.0 category feeds - 0/1 = off/on. # requires rss.sh plugin from nanoblogger-extra RSS_CATFEEDS="0" # --- Plugin: Articles Preferences --- # # sets the articles directory (path must be relative) # e.g. ARTICLES_DIR="articles articles/howtos notes" # will create three # sections of articles. # NOTE: defined directories are not automatically created for you. #ARTICLES_DIR="" # defaults to articles # default article text formatting (name of the text formatting plugin(s)). # e.g. markdown = plugins/page/format/markdown.sh ARTICLES_FORMAT="" # defaults to $PAGE_FORMAT # --- Cache Preferences --- # # maximum number of entries to store in cache (-1 = all) # TOTAL_ENTRIES=`grep -c "." $BLOG_DIR/data/master.db` # MAX_CACHE_ENTRIES=`expr $TOTAL_ENTRIES \/ 2` # divides $TOTAL_ENTRIES # MAX_CACHE_ENTRIES=`expr $MAX_ENTRIES \* 2` # multiplies $MAX_ENTRIES MAX_CACHE_ENTRIES="$MAX_ENTRIES" # defaults to $MAX_ENTRIES # set cache management to automatic (1) or manual (0) BLOG_CACHEMNG="1" # defaults to automatic (1) # --- Security Settings --- # # set temp directory (default is /tmp) #NB_TEMP_DIR="$BLOG_DIR/.tmp" # set default file permissions for newly created weblog files (defaults to # user's current umask) - refer to umask command for further details. #NB_UMASK="022" nanoblogger-3.4.2/default/cache/000755 000765 000024 00000000000 11336333423 017153 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/data/000755 000765 000024 00000000000 11336333423 017021 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/images/000755 000765 000024 00000000000 11336333423 017355 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/plugins/000755 000765 000024 00000000000 11336333423 017571 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/styles/000755 000765 000024 00000000000 11336333423 017433 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/templates/000755 000765 000024 00000000000 11336333423 020106 5ustar00kevinwstaff000000 000000 nanoblogger-3.4.2/default/templates/archive_index.htm000644 000765 000024 00000002345 11336117757 023446 0ustar00kevinwstaff000000 000000 $NB_MetaTitle | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink

$NB_MetaTitle

$NB_MetaBody
nanoblogger-3.4.2/default/templates/category_archive.htm000644 000765 000024 00000002364 11013740245 024137 0ustar00kevinwstaff000000 000000 $template_catarchives $NB_ArchiveTitle | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink

$template_catarchives $NB_ArchiveTitle

$NB_MetaBody
nanoblogger-3.4.2/default/templates/category_entry.htm000644 000765 000024 00000000620 11024410564 023650 0ustar00kevinwstaff000000 000000 $([ $MONTH_ARCHIVES = 1 ] && echo ''$month' -' || echo ''$month' -') $([ ! -z "$NB_EntryTitle" ] && echo ''$NB_EntryTitle'' || echo ''$notitle'') $([ ! -z "$NB_EntryCategories" ] && echo "- $NB_EntryCategories")
nanoblogger-3.4.2/default/templates/day_archive.htm000644 000765 000024 00000003312 11013740245 023071 0ustar00kevinwstaff000000 000000 $NB_ArchiveTitle $template_archives | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink

$NB_ArchiveTitle $template_archives

$NB_MetaBody
nanoblogger-3.4.2/default/templates/entry.htm000644 000765 000024 00000001217 10742555266 021775 0ustar00kevinwstaff000000 000000

$NB_EntryDate

$NB_EntryTitle

$NB_EntryBody

$template_postedby $NB_EntryAuthor $([ "$SHOW_PERMALINKS" = "1" ] && echo '| '$template_permlink'') $([ ! -z "$NB_EntryCategories" ] && echo "| $template_catlinks $NB_EntryCategories")
nanoblogger-3.4.2/default/templates/entry.metadata000644 000765 000024 00000000255 10742230262 022750 0ustar00kevinwstaff000000 000000 TITLE: $NB_EntryTitle AUTHOR: $NB_EntryAuthor DATE: $NB_EntryDate DESC: $NB_EntryDescription FORMAT: $NB_EntryFormat $METADATA_MARKER BODY: $NB_EntryBody $METADATA_CLOSEVAR nanoblogger-3.4.2/default/templates/file.metadata000644 000765 000024 00000000247 10742230262 022527 0ustar00kevinwstaff000000 000000 TITLE: $NB_MetaTitle AUTHOR: $NB_MetaAuthor DATE: $NB_MetaDate DESC: $NB_MetaDescription FORMAT: $NB_MetaFormat $METADATA_MARKER BODY: $NB_MetaBody $METADATA_CLOSEVAR nanoblogger-3.4.2/default/templates/main_index.htm000644 000765 000024 00000005005 11336315547 022742 0ustar00kevinwstaff000000 000000 $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink
$NB_MetaBody
nanoblogger-3.4.2/default/templates/main_links.htm000644 000765 000024 00000000140 10365473546 022753 0ustar00kevinwstaff000000 000000 $template_main
nanoblogger-3.4.2/default/templates/makepage.htm000644 000765 000024 00000002345 11013740245 022372 0ustar00kevinwstaff000000 000000 $NB_MetaTitle | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink

$NB_MetaTitle

$NB_MetaBody
nanoblogger-3.4.2/default/templates/month_archive.htm000644 000765 000024 00000003413 11013740245 023443 0ustar00kevinwstaff000000 000000 $NB_ArchiveTitle $template_archives | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink

$NB_ArchiveTitle $template_archives

$NB_MetaBody
nanoblogger-3.4.2/default/templates/month_entry.htm000644 000765 000024 00000001217 10745454122 023172 0ustar00kevinwstaff000000 000000

$NB_EntryDate

$NB_EntryTitle

$NB_EntryBody

$template_postedby $NB_EntryAuthor $([ "$SHOW_PERMALINKS" = "1" ] && echo '| '$template_permlink'') $([ ! -z "$NB_EntryCategories" ] && echo "| $template_catlinks $NB_EntryCategories")
nanoblogger-3.4.2/default/templates/permalink.htm000644 000765 000024 00000003776 11015170057 022613 0ustar00kevinwstaff000000 000000 $NB_EntryTitle | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink
$NB_MetaBody
nanoblogger-3.4.2/default/templates/permalink_entry.htm000644 000765 000024 00000001043 10742555266 024034 0ustar00kevinwstaff000000 000000

$NB_EntryDate

$NB_EntryTitle

$NB_EntryBody

$template_postedby $NB_EntryAuthor $([ "$SHOW_PERMALINKS" = "1" ] && echo '| '$template_permlink'') $([ ! -z "$NB_EntryCategories" ] && echo "| $template_catlinks $NB_EntryCategories")
nanoblogger-3.4.2/default/templates/weblog_status.htm000644 000765 000024 00000000260 10742230262 023475 0ustar00kevinwstaff000000 000000 $template_totalentries $TOTAL_ENTRIES
$template_lastentry $LAST_ENTRY_TIME
$template_lastupdated $LAST_UPDATED nanoblogger-3.4.2/default/templates/year_archive.htm000644 000765 000024 00000002663 11336117757 023302 0ustar00kevinwstaff000000 000000 $NB_MetaTitle | $BLOG_TITLE $NB_AtomAltLink $NB_RSS2AltLink $NB_RSSAltLink

$NB_MetaTitle

$NB_MetaBody
nanoblogger-3.4.2/default/styles/feed.css000644 000765 000024 00000005051 10555570662 021063 0ustar00kevinwstaff000000 000000 /* Make RSS and Atom feeds at least semi-legible to folk who accidentally load them in a browser... Compatibility: * Mozilla is fine. * Safari 1.2: the RSS text isn't shown * Opera 7.5 uses the style sheet instead of its native RSS mode. * IE/Mac 5.2: none of the :before content works; doesn't get the charset right and displays garbage for non-ASCII. * IE/Win 6.0: No background color, borders, font size, font weight, or :before content. */ /* RSS: */ rss, channel, title, link, description, language, generator, lastBuildDate, item, pubDate, author, comments, creator, /* Atom: */ feed, id, modified, tagline, entry, issued, created, updated, summary, comment { display: block; } rss, feed { background: white; color: black; margin: 1em; font-family: "Verdana", "Tahoma", "Arial", "Helvetica", sans-serif; line-height: 1.5em; font-size: 76%; } rss:before { content: "This RSS feed is meant to be read in a syndicated news reader, and isn't ideal for a web browser."; } feed:before { content: "This Atom feed is meant to be read in a syndicated news reader, and isn't ideal for a web browser."; } rss:before, feed:before { color: red; text-align: center; line-height: 2em; } channel>title, item>title, feed>title, entry>title { font-weight: bold; border-bottom: solid 1px #aaa; margin-left: -0.5em; } channel>title, feed>title { font-size: larger; } item>title, entry>title { font-size: large; } item, entry { margin-top: 1em; margin-left: 2em; } item>description, entry>summary { white-space: pre; overflow: auto; background: #f8f8ff; } pubDate:before { content: "Date: " } link:before { content: "Link: " } author:before, creator:before { content: "Author: " } description:before { content: "Description: " } id:before { content: "Id: " } generator:before { content: "Generator: " } language:before { content: "Language: " } lastBuildDate:before { content: "Updated: " } comments:before { content: "Comments page: " } tagline:before { content: "Tagline: " } issued:before { content: "Issued: " } created:before { content: "Created: " } modified:before { content: "Modified: " } updated:before { content: "Updated: " } summary:before { content: "Summary: " } comment:before { content: "Comment: " } pubDate:before, link:before, author:before, description:before, language:before, generator:before, lastBuildDate:before, comments:before, tagline:before, issued:before, created:before, modified:before, summary:before, comment:before, creator:before, id:before, updated:before { color: #224; font-weight: bold; } feed link:after { content: attr(href); } nanoblogger-3.4.2/default/styles/nb_clean.css000644 000765 000024 00000016506 11023267156 021720 0ustar00kevinwstaff000000 000000 /* NanoBlogger Clean Simple 2 column layout */ body { font: 12px/1.5 verdana, arial, sans-serif; background:#FFF; margin:0; padding:0; } a { color: #003365; text-decoration: none; } a:link { color: #003366; text-decoration: none; } a:visited { color: #003366; text-decoration: none; } a:active { color: #999999; } a:hover { color: #999999; } h1 { margin-top: 25px; margin-bottom: -0.25em; padding-top: 10px; font-family: palatino, georgia, verdana, arial, sans-serif; font-size:x-large; } h2 { color: #666; margin-bottom: 1.5em; padding: 0; text-align: center; font-family: palatino, georgia, verdana, arial, sans-serif; font-size: large; font-weight: bold; } h3 { margin-top: 1.5em; margin-bottom: -0.75em; padding: 0; color: #666; font-size: medium; } h4, h5, h6 { margin-top: 1.5em; margin-bottom: -0.75em; font-size: x-small; } blockquote { background-color:#EEE; padding:2mm; border-left:5px solid #BBB; } img { border: 0; } pre { background-color:#EEE; padding:2mm; border-top:2px solid #999; border-left:2px solid #999; border-right:1px solid #CCC; border-bottom:1px solid #CCC; } #banner { margin:0; padding:0; margin-top:0; font-family: palatino, georgia, verdana, arial, sans-serif; background-color: #FFF; color: #333; font-size:large; font-weight:normal; text-align:left; border-top:1px dotted #999; border-bottom:1px dotted #999; padding:15px; } #banner h1 { margin:0; padding:0 0 0 10px; font-size:x-large; } #banner a, #banner a:link, #banner a:visited, #banner a:active, #banner a:hover { font-family: palatino, georgia, verdana, arial, sans-serif; font-size:x-large; color: #333; text-decoration:none; } .description { color: #333; font-family: palatino, georgia, verdana, arial, sans-serif; font-size:small; font-weight:bold; text-transform:lowercase; padding:0 0 0 10px; } #content { margin:0; padding:0; margin-left:210px; background-color:#FFF; } #container { margin:0; padding:0; background-color:#FFF; } #links { margin:0; padding:0; float:left; width:204px; background-color:#FFF; border:1px solid #FFF; border-right: 1px dotted #999; padding:15px 0 15px 0; } #footer { margin:0; padding:0; clear:both; background-color:#999999; border-top:1px dotted #999; border-bottom:1px dotted #999; } .blog { margin:0; padding:0; padding:15px; } .archives { margin:0; padding:0; font-family: palatino, georgia, verdana, arial, sans-serif; color:#333; font-size:small; font-weight: normal; padding:15px; } .blogbody { font-family: palatino, georgia, verdana, arial, sans-serif; color:#333; font-size:small; font-weight:normal; line-height:120%; } .blogbody a, .blogbody a:link, .blogbody a:visited, .blogbody a:active, .blogbody a:hover { font-weight:normal; text-decoration:underline; } .title { font-family: palatino, georgia, verdana, arial, sans-serif; font-size:medium; color: #666; margin-bottom:15px; } #menu, .menu { font-family: palatino, georgia, verdana, arial, sans-serif; font-size:small; margin-top:25px; margin-bottom:25px; text-align:center; } .date { font-family: palatino, georgia, verdana, arial, sans-serif; font-size:large; color: #333; border-bottom:1px solid #999; margin-bottom:10px; font-weight:bold; line-height: 1.7em; text-align:left; } .posted { font-family: verdana, arial, sans-serif; font-size:x-small; color:#000000; margin-bottom:25px; } .articleshead { color: #666600; font-family: verdana, arial, sans-serif; font-weight:bold; text-transform:uppercase; } .calendar { color: #666; padding:2px; text-align:center; font-family: verdana, arial, sans-serif; font-size:x-small; font-weight:normal; } .calendar table { border-left:15px solid #FFF; border-right:15px solid #FFF; } .calendar a, .calendar a:link, .calendar a:active, .calendar a:hover { font-weight:bold; text-decoration:underline; } .calendarhead { color: #666600; padding:2px 15px 2px 15px; border-left:15px solid #FFF; border-right:15px solid #FFF; text-align:center; font-weight:bold; letter-spacing:0.2em; text-transform:uppercase; border-bottom:1px solid #999; } .calendarhead a, .calendarhead a:link, .calendarhead a:visited { text-decoration:none; } .calendarhead a:hover { text-decoration:underline; } .calendarday { font-weight:bold; text-align:center; } .side { color:#333; margin:0; padding:0; padding:2px 15px 2px 15px; font-family: verdana, arial, sans-serif; font-size:x-small; font-weight:normal; line-height:150%; } .sidetitle { color: #666600; font-family: palatino, georgia, verdana, arial, sans-serif; font-size:small; font-weight:normal; padding:2px; margin-top:10px; letter-spacing:0.1em; border-bottom:1px dotted #999; border-left:15px solid #FFF; border-right:15px solid #FFF; text-align:center; text-transform:uppercase; } .syndicate { font-family: verdana, arial, sans-serif; font-size:x-small; color:#666; background-color:#EEE; margin-top:10px; padding:2px 15px 2px 15px; border-left:15px solid #FFF; border-right:15px solid #FFF; line-height:150%; text-align:right; } .feed-small { height: 14px; padding-left: 15px; background: url('../images/feed-icon-14x14.png') no-repeat 0% 50%; } .powered { font-family: palatino, georgia, verdana, arial, sans-serif; font-size:x-small; line-height:150%; background-color:#EEE; color:#666; padding:2px 15px 2px 15px; border-left:15px solid #FFF; border-right:15px solid #FFF; text-align:center; } .comments-body { font-family: palatino, georgia, verdana, arial, sans-serif; color:#666; font-size:small; font-weight: normal; line-height: 120%; padding-bottom: 10px; padding-top: 10px; border-bottom: 1px dotted #999; } .comments-post { font-family: verdana, arial, sans-serif; color:#666; font-size:x-small; font-weight: normal; } .trackback-url { font-family: palatino, georgia, verdana, arial, sans-serif; color:#666; font-size:small; font-weight: normal; line-height: 150%; padding:5px; border:1px dotted #999; } .trackback-body { font-family: palatino, georgia, verdana, arial, sans-serif; color:#666; font-size:small; font-weight: normal; line-height: 120%; padding-bottom: 10px; padding-top: 10px; border-bottom: 1px dotted #999; } .trackback-post { font-family: verdana, arial, sans-serif; color:#666; font-size:x-small; font-weight: normal; } .comments-head { font-family: palatino, georgia, verdana, arial, sans-serif; font-size:small; color: #666; border-bottom: 1px solid #999; margin-top:20px; font-weight: bold; } #banner-commentspop { font-family: palatino, georgia, verdana, arial, sans-serif; color:#FFF; font-size:large; font-weight: bold; border-left: 1px solid #FFF; border-right: 1px solid #FFF; border-top:1px solid #FFF; padding-left: 15px; padding-right: 15px; padding-top: 5px; padding-bottom: 5px; } .intro { font-family: palatino, georgia, verdana, arial, sans-serif; border-bottom: 1px solid #999999; background-color:#FFF; color:#333; font-size:small; font-weight: normal; line-height: 140%; padding:10px 10px 0px 10px; margin-right:15px; margin-bottom: 45px; } .intro a, .intro a:link, .intro a:visited, .intro a:active, .intro a:hover { font-weight: normal; text-decoration: underline; color:#333; } .fortune { color: #555; font-family: palatino, georgia, verdana, arial, sans-serif; font-weight: normal; font-style: italic; font-size: x-small; padding:2px 15px 2px 15px; } nanoblogger-3.4.2/default/styles/nb_default.css000644 000765 000024 00000015726 11023267156 022265 0ustar00kevinwstaff000000 000000 /* NanoBlogger Silver Theme simple 2 column layout */ body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; background:#FFF; margin:0; padding:0; } a { color: #003366; text-decoration: none; } a:link { color: #003366; text-decoration: none; } a:visited { color: #003366; text-decoration: none; } a:active { color: #999999; text-decoration: underline; } a:hover { color: #999999; text-decoration: underline; } h1 { margin-bottom:-0.25em; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:x-large; } h2 { color:#999999; margin-bottom:1.5em; padding:0; text-align:center; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:large; font-weight:bold; } h3 { margin-top:1.5em; margin-bottom:-0.75em; padding:0; color:#003366; font-size:medium; } h4, h5, h6 { margin-top:1.5em; margin-bottom:-0.75em; font-size:x-small; } blockquote { background-color:#EEE; padding:2mm; border-left:5px solid #BBB; } pre { background-color:#EEE; padding:2mm; border-top:2px solid #999; border-left:2px solid #999; border-right:1px solid #CCC; border-bottom:1px solid #CCC; } #banner { margin:0; padding:0; margin-top:0; font-family: verdana, arial, sans-serif; background-color:#999999; font-size:large; font-weight:normal; text-align:left; border-top:1px dotted #999; border-bottom:1px dotted #999; padding:15px; } #banner h1 { margin:0; padding:0 0 0 10px; font-size:x-large; } #banner a, #banner a:link, #banner a:visited, #banner a:active, #banner a:hover { font-family: verdana, arial, sans-serif; font-size:x-large; color:#FFF; text-decoration:none; } .description { font-family: verdana, arial, serif; color:#FFF; font-size:small; font-weight:bold; text-transform:lowercase; padding:0 0 0 10px; } #content { margin:0; padding:0; margin-left:215px; background-color:#FFF; } #container { margin:0; padding:0; background-color:#FFF; } #links { margin:0; padding:0; float:left; width:199px; background-color:#FFF; border:1px solid #FFF; border-right: 1px dotted #999; padding:15px 0 15px 0; } #footer { margin:0; padding:0; clear:both; background-color:#999999; border-top:1px dotted #999; border-bottom:1px dotted #999; } .blog { margin:0; padding:0; padding:15px; } .archives { margin:0; padding:0; font-family: verdana, arial, sans-serif; color:#333; font-size:small; font-weight: normal; padding:15px; } .blogbody { font-family: verdana, arial, sans-serif; color:#333; font-size:small; font-weight:normal; line-height:120%; } .blogbody a, .blogbody a:link, .blogbody a:visited, .blogbody a:active, .blogbody a:hover { font-weight:normal; text-decoration:underline; } .title { font-family: verdana, arial, sans-serif; font-size:small; color:#003366; margin-bottom:15px; } #menu, .menu { font-family: verdana, arial, sans-serif; font-size:small; margin-top:25px; margin-bottom:25px; text-align:center; } .date { font-family: verdana, arial, sans-serif; font-size:small; color:#666; border-bottom:1px solid #999; margin-bottom:10px; font-weight:bold; text-align:left; } .posted { font-family: verdana, arial, sans-serif; font-size:x-small; color:#000000; margin-bottom:25px; } .articleshead { color:#003366; text-transform:lowercase; font-family: verdana, arial, sans-serif; font-weight:bold; } .calendar { color:#003366; padding:2px; text-align:center; font-family: verdana, arial, sans-serif; font-size:x-small; font-weight:normal; } .calendar table { border-left:15px solid #FFF; border-right:15px solid #FFF; } .calendar a, .calendar a:link, .calendar a:active, .calendar a:hover { font-weight:bold; text-decoration:underline; } .calendarhead { color:#003366; padding:2px 15px 2px 15px; border-left:15px solid #FFF; border-right:15px solid #FFF; text-align:center; font-weight:bold; letter-spacing:0.2em; text-transform:uppercase; border-bottom:1px solid #999; } .calendarhead a, .calendarhead a:link, .calendarhead a:visited { text-decoration:none; } .calendarhead a:hover { text-decoration:underline; } .calendarday { font-weight:bold; text-align:center; } .side { margin:0; padding:0; padding:2px 15px 2px 15px; font-family: verdana, arial, sans-serif; color:#333; font-size:x-small; font-weight:normal; line-height:150%; } .sidetitle { font-family: verdana, arial, sans-serif; color:#003366; font-size:small; font-weight:normal; padding:2px; margin-top:10px; letter-spacing:0.1em; border-bottom:1px dotted #999; border-left:15px solid #FFF; border-right:15px solid #FFF; text-align:center; text-transform:lowercase; } .syndicate { font-family: verdana, arial, sans-serif; font-size:x-small; color:#666; background-color:#EEE; margin-top:10px; padding:2px 15px 2px 15px; border-left:15px solid #FFF; border-right:15px solid #FFF; line-height:150%; text-align:right; } .feed-small { height: 14px; padding-left: 15px; background: url('../images/feed-icon-14x14.png') no-repeat 0% 50%; } .powered { font-family: verdana, arial, sans-serif; font-size:x-small; line-height:150%; background-color:#EEE; color:#666; padding:2px 15px 2px 15px; border-left:15px solid #FFF; border-right:15px solid #FFF; text-align:center; } .comments-body { font-family: verdana, arial, sans-serif; color:#666; font-size:small; font-weight: normal; line-height: 120%; padding-bottom: 10px; padding-top: 10px; border-bottom: 1px dotted #999; } .comments-post { font-family: verdana, arial, sans-serif; color:#666; font-size:x-small; font-weight: normal; } .trackback-url { font-family: verdana, arial, sans-serif; color:#666; font-size:small; font-weight: normal; line-height: 150%; padding:5px; border:1px dotted #999; } .trackback-body { font-family: verdana, arial, sans-serif; color:#666; font-size:small; font-weight: normal; line-height: 120%; padding-bottom: 10px; padding-top: 10px; border-bottom: 1px dotted #999; } .trackback-post { font-family: verdana, arial, sans-serif; color:#666; font-size:x-small; font-weight: normal; } .comments-head { font-family: verdana, arial, sans-serif; font-size:small; color: #666; border-bottom: 1px solid #999; margin-top:20px; font-weight: bold; } #banner-commentspop { font-family: verdana, arial, sans-serif; color:#FFF; font-size:large; font-weight: bold; border-left: 1px solid #FFF; border-right: 1px solid #FFF; border-top:1px solid #FFF; padding-left: 15px; padding-right: 15px; padding-top: 5px; padding-bottom: 5px; } .intro { font-family: verdana, arial, sans-serif; border-bottom: 1px solid #003366; background-color:#FFF; color:#333; font-size:small; font-weight: normal; line-height: 140%; padding:10px 10px 0px 10px; margin-bottom: 45px; } .intro a, .intro a:link, .intro a:visited, .intro a:active, .intro a:hover { font-weight: normal; text-decoration: underline; color:#333; } .fortune { color: #555; font-family: verdana, arial, sans-serif; font-weight: normal; font-style: italic; font-size: x-small; padding:2px 15px 2px 15px; } nanoblogger-3.4.2/default/styles/print.css000644 000765 000024 00000003606 10646217221 021306 0ustar00kevinwstaff000000 000000 /* based on print style sheet by Eric Meyer www.alistapart.com/articles/gointoprint */ html { font-family: verdana, arial, sans-serif; background: white; } body { background: white; font-size: 12pt; } h1 { font-size:large; } h2 { text-align:center; font-size:large; font-weight:bold; } h3 { font-size:medium; } .powered { display: none; } #menu, .menu { display: none; } #links { display: none; } #content, #container { width: auto; margin: 0 5%; padding: 0; border: 0; float: none !important; color: black; background: transparent none; } div#content { margin-left: 5%; padding-top: 1em; border-top: 1px solid #930; } div#banner { background: transparent; margin-bottom: -8px; } div#banner img { vertical-align: bottom; } #banner a:active, #banner a:visited, #banner a:link { color: black; } div.blogbody, div.archives { font-family: verdana, arial, sans-serif; font-size:small; font-weight:normal; } .date { font-family: verdana, arial, sans-serif; font-size: small; color: #666666; } .title { font-family: verdana, arial, sans-serif; font-size: small; color: #3A3A3A; } .description { color: black; } blockquote, pre { color: black; background: transparent; } a:link, a:visited { color: #520; font-weight: bold; background: transparent; text-decoration: underline; } /* include href attribute in parenthesis next to links */ #content a:active:after, #content a:visited:after, #content a:link:after { content: " (" attr(href) ") "; font-size: 90%; } #container a:active:after, #container a:visited:after, #container a:link:after { content: " (" attr(href) ") "; font-size: 90%; } /* This is a valid CSS3 selector */ /* #content a[href^="/"]:after { content: " (http://www.example.com/" attr(href) ") "; } */ nanoblogger-3.4.2/default/images/favicon.ico000644 000765 000024 00000002576 10145015340 021500 0ustar00kevinwstaff000000 000000 h( @www:::[[[ NNN...fff&&&BBBnnnTTTaaa  888ddd8A''''''''''''8>88B82$31)8)-"D/26?8C7*E/%)@8C7 +=+ 98C-4;(<0 >8C)/#!<85 : ., 8B8B82&8BBBBBBBBBBBBB888888888888888nanoblogger-3.4.2/default/images/feed-icon-14x14.png000644 000765 000024 00000001261 10532161342 022467 0ustar00kevinwstaff000000 000000 PNG  IHDRH-gAMA7tEXtSoftwareAdobe ImageReadyqe<CIDATxڌMHaδ1E"!HD*(PKtPnEХ:oAAHBRQ!%B]Y; ys4I@#֒Ps ZH sYLKDzzdR`TB ~;Ub# 4b^)uk)C2̝KhJlMlhim~&@eI25 K,M mGa<]ao% ޏ/q'Qʽbv[M)`q~fBYxaqd dg)BWM7H^lP@Qzz֦`H/7JeyJ%W\If m}XX\^+`_ǹ\,űX{+17j6+NDuZ(5]t6j.<&m+ARDž) ݬN GhȮ4ytPZ*k`r4M1MDC E2X$? GbIENDB`nanoblogger-3.4.2/default/data/cat_1.db000644 000765 000024 00000000021 11015602511 020277 0ustar00kevinwstaff000000 000000 nanoblogger-help nanoblogger-3.4.2/default/articles/example.txt000644 000765 000024 00000002036 11063754470 022121 0ustar00kevinwstaff000000 000000 TITLE: Example Article AUTHOR: n1xt3r DATE: DESC: example article for nanoblogger FORMAT: raw ----- BODY:

This is an example article created by the default articles plugin, which is a plugin that acts like a conduit for adding additional content to your weblog. The plugin works by scanning the articles directory for files ending with ".txt" that are new or have been recently modified and refreshes the articles accordingly.

New articles can easily be created using the add article action.

nb [--title 'Example Article'] add article

New articles can also be created manually using the draft, query and update actions.

nb draft [blog_dir]articles/example.txt
nb update main [publish]
To remove an article simply rename it's suffix to something other than ".txt" or remove it from the articles directory ...

... followed by a quick:
nb update main [publish]

View this article's meta-file.

END-----