build a fulltext-searchable databose for the blog
This commit is contained in:
parent
9dcb4e9b14
commit
998794db4a
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
_site
|
||||
.rake_tasks~
|
||||
blog.db
|
||||
|
|
7
Makefile
7
Makefile
|
@ -1,5 +1,6 @@
|
|||
SOURCE = /home/jer/git/fnordig.de/_site/
|
||||
DEST = /var/www/sites/fnordig.de/
|
||||
DATABASE_PATH = blog.db
|
||||
|
||||
default:
|
||||
rm -rf _site
|
||||
|
@ -18,10 +19,14 @@ serve: build
|
|||
cd _site && http
|
||||
.PHONY: serve
|
||||
|
||||
deploy: clean build
|
||||
deploy: clean build index
|
||||
rsync -va --delete $(SOURCE) $(DEST)
|
||||
.PHONY: deploy
|
||||
|
||||
index:
|
||||
DATABASE_PATH="$(DATABASE_PATH)" ./index.sh
|
||||
.PHONY: index
|
||||
|
||||
clean:
|
||||
cobalt clean
|
||||
.PHONY: clean
|
||||
|
|
|
@ -24,6 +24,8 @@ ignore:
|
|||
- ext/
|
||||
- README.md
|
||||
- Makefile
|
||||
- index.sh
|
||||
- blog.db
|
||||
syntax_highlight:
|
||||
theme: "InspiredGitHub"
|
||||
assets:
|
||||
|
|
25
index.sh
Executable file
25
index.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
DATABASE_PATH="${DATABASE_PATH:-blog.db}"
|
||||
sqlite3 -batch -bail "$DATABASE_PATH" "
|
||||
CREATE TABLE IF NOT EXISTS [posts] (
|
||||
[_id] TEXT PRIMARY KEY,
|
||||
[_path] TEXT,
|
||||
[text] TEXT,
|
||||
[html] TEXT,
|
||||
[permalink] TEXT,
|
||||
[title] TEXT,
|
||||
[published_date] TEXT,
|
||||
[layout] TEXT,
|
||||
[data] TEXT,
|
||||
[excerpt] TEXT
|
||||
);
|
||||
PRAGMA journal_mode = WAL;
|
||||
PRAGMA foreign_keys = ON;
|
||||
" >/dev/null
|
||||
|
||||
markdown-to-sqlite "$DATABASE_PATH" posts _posts/*
|
||||
sqlite-utils enable-fts --fts5 "$DATABASE_PATH" posts title text 2>/dev/null || true
|
||||
sqlite-utils rebuild-fts "$DATABASE_PATH" posts
|
Loading…
Reference in a new issue