From 52b67951f1e8a7f1af9b85d4ae8e7689d194574a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 3 Aug 2015 17:43:40 +0200 Subject: Working prototype in hakyll --- posts/blog-documentation.md | 5 -- posts/blog-rss.md | 39 --------------- posts/pwutil.md | 119 -------------------------------------------- 3 files changed, 163 deletions(-) delete mode 100644 posts/blog-documentation.md delete mode 100644 posts/blog-rss.md delete mode 100644 posts/pwutil.md (limited to 'posts') diff --git a/posts/blog-documentation.md b/posts/blog-documentation.md deleted file mode 100644 index 7db843d..0000000 --- a/posts/blog-documentation.md +++ /dev/null @@ -1,5 +0,0 @@ -% On the Origin of dirty-haskell.org - -The software used is a trivially modified version of the one powering [math.kleen.org](http://math.kleen.org/lists/blog.html). - -The title is without deeper meaning. \ No newline at end of file diff --git a/posts/blog-rss.md b/posts/blog-rss.md deleted file mode 100644 index 4e8cb24..0000000 --- a/posts/blog-rss.md +++ /dev/null @@ -1,39 +0,0 @@ -% dirty-haskell.org´s rss feeds - -I extended the software suite inherited from [math.kleen.org](http://math.kleen.org) to include support for rss feeds. -The heart of the issue is a ~80 line haskell script I chose to call, in a bout of creativity, "generate-rss.hs". -The script uses the [feed](http://hackage.haskell.org/package/feed-0.3.9.2) package. - -generate-rss.hs gets passed a title and a list of paths below ./lists to incorporate as items. -It generates an empty feed structure, adds title and a (hardcoded) base url for RSS metadata, and iterates over the given paths — generating for each path an item to be included in the finished feed. -This procedure makes use of a state monad (StateT (Feed, Maybe ClockTime) IO ()) to sequentially add items to the feed and keep track of the modification/change time of the newest path examined. -Each item carries a title, an url, a date, and contents as follows: - -- The date used is the modification/change time of the path supplied as a command line argument at the beginning of the program (usually a symbolic link in ./lists) — as such it is the time the post was linked into the particular list we´re generating a RSS feed for (this was not a deliberate design choice but a side effect of the canonical implementation — it was later decided that this behaviour was in fact the one expected all along). -- The url is generated by following, recursively, the trail of symbolic links starting in ./lists, assuming the final target is indeed in ./posts, and forming the filename of that target into a (hopefully) functional url in a hardcoded fashion. -- The title is extracted from the markdown file using a function shamelessly copied from extract-title.hs (The author wrote that one too, after all). -- The contents are read into Pandoc and rendered into [AsciiDoc](http://en.wikipedia.org/wiki/AsciiDoc) format (it seemed convenient at the time). - -Along the way two helper functions were introduced — if an implementation of those already exists in Prelude or somewhere else common please mail in a comment: - -~~~ {.haskell} -(<->) :: [(a -> b)] -> a -> [b] -[] <-> _ = [] -(f:fs) <-> x = (f x:fs <-> x) - -(<-->) :: [(a -> a)] -> a -> a -[] <--> x = x -(f:fs) <--> x = fs <--> (f x) -~~~ - -## Update ## - -~~~ {.haskell} -import Control.Applicative ((<*>), pure) - -(<->) fs = (<*>) fs . pure - -(<-->) = flip $ foldl (.) id -~~~ - -Thanks, viktor. diff --git a/posts/pwutil.md b/posts/pwutil.md deleted file mode 100644 index 176ffdc..0000000 --- a/posts/pwutil.md +++ /dev/null @@ -1,119 +0,0 @@ -% A Tool to Manage a Set of YAML Objects Representing Account Information — pwutil - -A long time ago I wrote a bunch of scripts (first in bash, then zsh, and later perl) to manage a, sometimes encrypted, file containing account information I get asked to create and remember on a daily basis—accounts for shopping websites spring to mind. - -[pwutil](git://git.yggdrasil.li/pwutil) is the newest iteration in this line of bunches of scripts. - -## Features - - * Support for embedding common operation in any kind of record keeping - - Thus support for almost any encryption known to man (with absolutely no online security), version control, and synchronisation - * [Human read- and writeable](https://en.wikipedia.org/wiki/YAML) backstore - * Machine parseable output - * [Command Line Interface](https://en.wikipedia.org/wiki/Command-line_interface)-only - * New accounts can be partially generated by user defined functions with out of the box support for [pwgen](http://sourceforge.net/projects/pwgen/) and SSH - -## Usage - -~~~ -pwget [ …] -Looks up and returns all accounts which contain any anywhere in their representation — case insensitive. - -pwadd [[--gen- [ …] …] --] [ …] -Adds an account to the store — does not overwrite. -~~~ - -## Documentation - -I shall document the project in a partial and file-wise fashion—amendments available on request. - -### Structure - -~~~ {#DirTree} -pwutil -├── default.nix -├── PWAdd.hs -├── PWGet.hs -├── PWUtil -│   ├── Extra -│   │   ├── PWGen.hs -│   │   └── SSHCmd.hs -│   ├── Types.hs -│   └── Util.hs -├── pwutil.hs -├── PWUtil.hs -└── pwutil.nix -~~~ - -### `pwutil.nix` -is a [nix](https://nixos.org/nix) expression allowing easy installation using the nix package manager. -A `~/.nixpkgs/config.nix` allowing one to do so might look thus: - -~~~ {.numberLines} -{ - packageOverrides = pkgs: { - pwutil = pkgs.callPackage /path/to/pwutil.nix {}; - }; -} -~~~ - -The derivation takes some arguments (write those in `{}` above): - -`main ? null` - ~ Overwrite `pwutil.hs` with a file path - -`with ? false` - ~ `` is one of Pwgen, or Ssh a the current time. - If `true` wraps executables to have `$PATH` include ``. - -### `Types.hs` - -Introducing `PW` (much as [xmonad](https://xmonad.org) did with `X`) is an easy way to keep track of the `PWConfig` without resorting to function arguments. -`BackStore` is our (new and improved) way of encapsulating store access in a totally customisable way—`plain`, which is essential `readFile` and `writeFile` as provided by `ByteString`, is provided for convenience in `Util.hs`. -`PWConfig` most importantly contains a definition of generators (called by passing `--gen-…` to `pwadd`). - -~~~ {#Types.hs .haskell .numberLines} -module PWUtil.Types ( - PW(..), - BackStore(..), - PWConfig(..), - Generator(..) - ) where - -import Control.Monad.State -import qualified Data.Map as M -import Data.Yaml -import Data.ByteString - -type PW = StateT PWConfig IO - -data BackStore = BackStore - { readContents :: PW ByteString - , writeContents :: ByteString -> PW () - } - -data PWConfig = PWConfig - { generators :: M.Map String Generator - , backstore :: BackStore - } - -type Generator = [String] -> PW Value -~~~ - - -### `pwutil.hs` - -is, in a [xmonad](http://xmonad.org) kind of way, the configuration file—the shipped default is reproduced below as a template for custom configs. - -~~~ {#pwutil.hs .haskell .numberLines} -import PWUtil - -import System.FilePath (()) -import System.Directory (getHomeDirectory) - -main :: IO () -main = do - h <- getHomeDirectory - runPW (emptyConfig { backstore = plain (h "accounts.yaml") }) pwutil -~~~ -- cgit v1.2.3