Commit Graph

320 Commits

Author SHA1 Message Date
Martijn Dekker 2a29b22a7a Fix renaming using 'bb.sh edit -n'. Suppress 'which' errmsg.
edit(): The -n functionality (to rename files according to new title) was
broken. After renaming, files were accessed by the old name and not found,
or empty files were recreated under the old name, or both. Fixes:
- Move 'touch' commands for restoring time stamps to more opportune places.
- When renaming, save old file name to exclude it from $relevant_posts.

global_variables(): suppress GNU 'which' error message on setting markdown_bin.
2016-09-06 08:41:36 +02:00
Martijn Dekker 62a26bb575 Merge remote-tracking branch 'upstream/master'
Resolve minor editing 2.6-to-2.7 editing conflict in bb.sh
2016-09-06 03:45:35 +02:00
Martijn Dekker 54cc0c8060 More code refactoring. Limit word splitting and disable globbing by default.
- Globally, now do word splitting (IFS) only on newline (which also makes
  "$*" expand with newline separator instead of space).

- Disable globbing (pathmame expansion), to be re-enabled locally using
  'set +f' where needed (typically in a subshell).

These changes help eliminate unexpected snags and security vulnerabilities
in case someone forgets to quote a variable somewhere. They should also make
the code "just work" with spaces and other special characters in file names
and tags (as long as they're not newline characters, but that can't happen
with regular use of the script as the newline is the separator). This means
that, as of this change, editing or completely emptying the convert_filename
filter should no longer pose any problems as far as bb.sh is concerned.

The changes to adapt the code to the above are mainly:

- Now that we do word splitting on newline only, we can go back to iterating
  through files in a "for" loop instead of using "read" with a here-document,
  which is more readable. However, to enable globbing locally, a technique
  adaptation is needed, like:
     for file in $(set +f; printf '%s\n' *.html)
  or
     for file in $(set +f; ls -t -- *.html)  # sort by date, newest first
  Given IFS=$'\n' and globbing disabled globally, this technique is robust
  for all special characters in file names except for newlines.

- invoke_editor() function replaces direct $EDITOR calls, because we need to
  locally word-split $EDITOR on spaces in case it contains arguments.

- parse_file(): rewrite tag parsing to handle possible spaces in tags

- tags_in_post(): output line-separated instead of space-separated tags;
  further adjust sed script to handle possible spaces in tags

- rebuild_tags(): this function was refactored to use an array internally.
  Instead of two combined strings, it now takes HTML files and tags as
  separate arguments, separated by a single "--tag" argument. This allows
  for spaces and other special characters in both file names and tags. (See
  also commit a674ec5, which started this but didn't finish it).
2016-09-06 03:24:01 +02:00
Carlos Fenollosa a36566a90c Update README.md 2016-04-26 16:48:24 +02:00
Carlos Fenollosa 2b8b02ac58 simplified a couple commands and removed debug echos 2016-04-26 16:29:25 +02:00
Carlos Fenollosa a08f47bb69 Store post dates in html comment. Sync those with filesystem. Closes #96 2016-04-26 16:16:35 +02:00
Carlos Fenollosa 09fa553233 avoid the user mistakingly using 'edit <draft>' instead of 'post <draft>' 2016-04-25 21:14:24 +02:00
Carlos Fenollosa dd3c8a4a11 Merge pull request #105 from louwers/patch-1
Added support for images and made author field optional
2016-04-25 20:28:28 +02:00
Bart 1f4d3dd2bf Added support for images and made author field optional
One LOC per feature, hope you think it's worth it. http://imgur.com/YcBp29ql.png
2016-04-13 01:19:30 +02:00
Martijn Dekker d1a84d6eec Merge remote-tracking branch 'upstream/master' 2016-03-09 05:28:44 +01:00
Martijn Dekker a674ec5837 rebuild_tags(): use array for more robust file handling 2016-03-09 05:26:20 +01:00
Carlos Fenollosa 9ac5989932 Merge branch 'master' of github.com:cfenollosa/bashblog 2016-03-02 20:35:13 +01:00
Carlos Fenollosa b22d968278 'rebuild' now keeps original author. Fixes #99 2016-03-02 20:34:54 +01:00
Carlos Fenollosa 48f1fd465f Merge pull request #103 from platschi/master
remove topsy, their website now gets forwarded to apple support
2016-02-25 20:18:22 +01:00
platschi 10078f28cb remove topsy, their website now gets forwarded to apple support 2016-02-23 16:18:47 -03:00
Carlos Fenollosa 93d6877a38 fix #94 #97 2016-02-08 10:25:43 +01:00
Carlos Fenollosa 93717bc9b8 Merge pull request #87 from McDutchie/master
Some more optimizations
2016-02-08 10:16:38 +01:00
Carlos 7d60c63ec5 fix #85 2016-01-29 15:57:15 +01:00
Martijn Dekker e3cf406bd1 test_markdown() without temporary files
- A much shorter test_markdown() function that compares output directly
  rather than using temp files.
- Revert to using 'which' rather than 'command -v' for using the markdown binary
  because 'command -v' will find the markdown() shell function.
2016-01-19 00:12:53 +01:00
Martijn Dekker 9794f1635a fix unquoted $global_disqus_username that shellcheck.net didn't catch
(it was subject to field splitting and globbing)
2016-01-18 21:35:29 +01:00
Martijn Dekker c3e0572be6 Get rid of a couple of more shellcheck.net warnings. 2016-01-18 21:05:06 +01:00
Martijn Dekker 7771fab820 Some more code and performance optimisations
- Use builtin 'command -v' rather than external 'which'.
- The clean_filename() function just removed the initial ./ from a file
  name; do this with a parameter substitution instead. This gets rid of the
  need to fork subshells for command substitutions, so is much faster.
- Where convenient, replace 'echo ... | sed ...' with fast parameter
  substitutions.
2016-01-18 20:18:23 +01:00
Martijn Dekker c683019d7c XHTML compliance fix: self-close meta tag 2016-01-18 20:08:52 +01:00
Carlos 044e53d56c updated README 2016-01-15 09:47:39 +01:00
Carlos 62ef0f4a98 updated changelog 2016-01-14 16:42:33 +01:00
Carlos 5ee22cf7b4 Update the 'not abandoned by' date 2016-01-14 16:40:46 +01:00
Carlos 37bef699bf fixed posts singular/plural 2016-01-14 16:39:56 +01:00
Carlos 6b5e7c1e77 Line breaks in README.md 2016-01-14 16:33:10 +01:00
Carlos b71973e683 Added 'tags' command 2016-01-14 16:30:01 +01:00
Carlos dd3c9e171f Changed copyright year and version number 2016-01-14 16:01:22 +01:00
Carlos Fenollosa 0cff2a11db Merge pull request #82 from McDutchie/master
Various code cleanups
2016-01-14 16:00:11 +01:00
Martijn Dekker 18d2df26ce fix: allow field splitting on tags_with_posts call
Quoted one too many there.
2016-01-11 18:56:39 +01:00
Martijn Dekker b3b0545c7f more robust parsing of 'ls' using 'read'
* Iterating through 'ls' output using 'for' is very brittle; it relies on word splitting and globbing can also mess it up. It's best to use globs directly, but if using 'ls' cannot be avoided, e.g. if you need to sort by date, at least we can use 'IFS= read -r $i' to read from a here-document filled with the 'ls' output, which leaves everything in file names intact except newlines.
* Other minor cleanups.
2016-01-11 16:10:17 +01:00
Martijn Dekker a0aa994e17 Code cleanups: quoting, redirection, string handling
- Fix lots of problems with convoluted and broken quoting techniques.
- Group code blocks for redirection into a file rather than doing a separate additive redirect for each command.
- Replace strings using bash parameter substitution rather than piping 'echo' through 'sed', resulting in a faster script.
2016-01-11 03:30:41 +01:00
Martijn Dekker ba012c436e More correct and effective use of arrays 2016-01-11 00:16:50 +01:00
Martijn Dekker 2b24132f3c Consistent use of [[ and (( instead of [
Another minor code cleanup. Within [[ ... ]] and (( ... )) (but not [ ... ]) there is a different shell parsing context in which field splitting (a.k.a. word splitting) and pathname expansion (a.k.a. filename globbing) don't apply, so consistently use '[[' (and '((' for arithmetics) instead of '[' and remove unnecessary quotes.

Since '[[ x == y]]' does 'case'-like glob pattern matching on 'y', the quotes to the right of '==' need to be kept for variables or glob characters, except if a glob pattern is wanted.
2016-01-10 23:17:48 +01:00
Martijn Dekker f3329f0a82 Remove unnecessary quotes from scalar assignments
Substitutions (variables, command substitutions, etc.) directly assigned to a scalar variable don't need to be quoted, as field splitting and globbing don't apply in that context. Removing superfluous quotes makes the code look a bit cleaner.
2016-01-10 19:31:49 +01:00
Carlos ab91e5dda1 topsy is kill 2015-12-21 19:49:34 +01:00
Carlos Fenollosa 982b8a108d Update README.md 2015-11-13 16:30:19 +01:00
Carlos 54fdb360ab Shellcheck. Fix #78 2015-09-23 17:43:44 +02:00
Carlos Fenollosa f891d262da Merge pull request #80 from damateos/adaptative
little changes in css to adapt width to screen
2015-09-23 17:28:14 +02:00
David Mateos 81942377b7 little changes in css to adapt width to screen
width in px changed by percentage in main.css and meta tag viewport
added.
2015-09-02 11:30:47 +02:00
Carlos f90c439814 fixed bug where drafts were appended a random postfix after re-editing 2015-07-11 12:10:25 +02:00
Carlos Fenollosa fab3bc1054 Update README.md 2015-05-13 13:22:01 +02:00
Carlos Fenollosa 1a92bd7700 Update README.md 2015-05-13 13:18:11 +02:00
Carlos Fenollosa 088eebd621 Merge pull request #77 from vielmetti/patch-1
Update the "not abandoned by" date
2015-05-13 13:15:05 +02:00
Edward Vielmetti d161020afa Update the "not abandoned by" date 2015-05-13 06:43:52 -04:00
Carlos Fenollosa ec01889d91 Merge pull request #75 from Enneka/master
Fixes #70
2015-05-12 17:20:34 +02:00
Enneka ee711aee64 Fixes #70 2015-05-09 18:06:25 -04:00
Carlos Fenollosa 95854e9dfe Close #72 2015-03-09 11:21:15 +01:00