~cadence/bliz

ref: 7efd8ef0cc5876de7e6ae383b2d0ef22d3ee9351 bliz/src/script-includes.fish -rw-r--r-- 1.0 KiB
7efd8ef0Cadence Ember Fix mime meta line 1 year, 11 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function bliz_word_count
    sed -n '/^%%%/,/^%%%/d;/^% /d;p' $blizfile | wc -w
end

function bliz_hits
    set -l database_path personal/hits.db
    set -l safe_path (string escape --style=var -- $req_path)
    sqlite3 $database_path "\
        create table if not exists Hits (path TEXT, hits INTEGER, primary key (path)); \
        insert into Hits (path, hits) values ('$safe_path', 1) on conflict (path) do update set hits = hits + 1; \
        select hits from Hits where path = '$safe_path' \
        "
end

function gemlog_intro_meta
    set -l words (bliz_word_count)
    set -l minutes (expr \( $words + 150 \) / 300)
    set -l hits (bliz_hits)
    set -l base (basename $blizfile)
    set -l published (string match -r -- '^(?:[0-9]+-){2}[0-9]+' $base)
    echo "> $words words, about $minutes minutes to read at a reasonable 300 wpm."
    echo "> First published on $published."
    echo "> This article has been loaded $hits times."
end

test -f personal/script-includes.fish; and source personal/script-includes.fish