diff --git a/dbmigrations/00004.sql b/dbmigrations/00004.sql index 6801bfc..d06a386 100644 --- a/dbmigrations/00004.sql +++ b/dbmigrations/00004.sql @@ -1,3 +1,3 @@ create view view_posts_with_title as select id, path, title, content, published, updated, blog, section from (select p.rowid as id, p.path as path, pp.value as title, content, published, updated, blog, section from posts p left outer join post_parameters pp on p.path = pp.path where pp.parameter = 'title'); create virtual table posts_fts using fts5(path unindexed, title, content, published unindexed, updated unindexed, blog unindexed, section unindexed, content=view_posts_with_title, content_rowid=id); -insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file +-- insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file diff --git a/dbmigrations/00005.sql b/dbmigrations/00005.sql index d442550..d16741d 100644 --- a/dbmigrations/00005.sql +++ b/dbmigrations/00005.sql @@ -1,3 +1,3 @@ drop view view_posts_with_title; create view view_posts_with_title as select id, path, title, content, published, updated, blog, section from (select p.rowid as id, p.path as path, pp.value as title, content, published, updated, blog, section from posts p left outer join (select * from post_parameters where parameter = 'title') pp on p.path = pp.path); -insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file +-- insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file diff --git a/dbmigrations/00009.sql b/dbmigrations/00009.sql index 2392f0d..bd5da81 100644 --- a/dbmigrations/00009.sql +++ b/dbmigrations/00009.sql @@ -4,4 +4,4 @@ drop view view_posts_with_title; drop table posts_fts; create view view_posts_with_title as select id, path, title, content, published, updated, blog, section, status from (select p.rowid as id, p.path as path, pp.value as title, content, published, updated, blog, section, status from posts p left outer join post_parameters pp on p.path = pp.path where pp.parameter = 'title'); create virtual table posts_fts using fts5(path unindexed, title, content, published unindexed, updated unindexed, blog unindexed, section unindexed, status unindexed, content=view_posts_with_title, content_rowid=id); -insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file +-- insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file diff --git a/dbmigrations/00015.sql b/dbmigrations/00015.sql index 3679962..93960d1 100644 --- a/dbmigrations/00015.sql +++ b/dbmigrations/00015.sql @@ -1,3 +1,3 @@ drop view view_posts_with_title; create view view_posts_with_title as select p.rowid as id, p.path as path, coalesce(pp.value, '') as title, content, published, updated, blog, section, status from posts p left outer join (select * from post_parameters pp where pp.parameter = 'title') pp on p.path = pp.path; -insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file +-- insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file diff --git a/dbmigrations/00017.sql b/dbmigrations/00017.sql index 103cb2f..5f2f441 100644 --- a/dbmigrations/00017.sql +++ b/dbmigrations/00017.sql @@ -11,7 +11,7 @@ alter table posts_new rename to posts; create view view_posts_with_title as select p.rowid as id, p.path as path, coalesce(pp.value, '') as title, content, published, updated, blog, section, status, priority from posts p left outer join (select * from post_parameters pp where pp.parameter = 'title') pp on p.path = pp.path; drop table posts_fts; create virtual table posts_fts using fts5(path unindexed, title, content, published unindexed, updated unindexed, blog unindexed, section unindexed, status unindexed, priority unindexed, content=view_posts_with_title, content_rowid=id); -insert into posts_fts(posts_fts) values ('rebuild'); +-- insert into posts_fts(posts_fts) values ('rebuild'); create index index_posts_status on posts (status); create index index_posts_blog on posts (blog); create index index_posts_section on posts (section); diff --git a/dbmigrations/00019.sql b/dbmigrations/00019.sql index 1ef600f..7ac4cf9 100644 --- a/dbmigrations/00019.sql +++ b/dbmigrations/00019.sql @@ -1,2 +1,2 @@ update posts set published = toutc(published), updated = toutc(updated); -insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file +-- insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file diff --git a/dbmigrations/00023.sql b/dbmigrations/00023.sql new file mode 100644 index 0000000..bcbea6d --- /dev/null +++ b/dbmigrations/00023.sql @@ -0,0 +1,5 @@ +drop table posts_fts; +drop view view_posts_with_title; +create view posts_fts_view as select p.rowid as id, p.path as path, coalesce(pp.value, '') as title, p.content as content from posts p left outer join (select * from post_parameters pp where pp.parameter = 'title') pp on p.path = pp.path; +create virtual table posts_fts using fts5(path unindexed, title, content, content=posts_fts_view, content_rowid=id); +insert into posts_fts(posts_fts) values ('rebuild'); \ No newline at end of file diff --git a/main.go b/main.go index 7d747bd..a570e60 100644 --- a/main.go +++ b/main.go @@ -89,7 +89,7 @@ func main() { // Execute pre-start hooks app.preStartHooks() - // Initialize database and markdown + // Initialize database if err = app.initDatabase(true); err != nil { app.logErrAndQuit("Failed to init database:", err.Error()) return diff --git a/markdown.go b/markdown.go index f805828..f1e9e81 100644 --- a/markdown.go +++ b/markdown.go @@ -16,6 +16,10 @@ import ( ) func (a *goBlog) initMarkdown() { + if a.md != nil && a.absoluteMd != nil && a.titleMd != nil { + // Already initialized + return + } defaultGoldmarkOptions := []goldmark.Option{ goldmark.WithRendererOptions( html.WithUnsafe(), diff --git a/postsDb.go b/postsDb.go index 523112a..0dad166 100644 --- a/postsDb.go +++ b/postsDb.go @@ -291,7 +291,7 @@ func buildPostsQuery(c *postsRequestConfig, selection string) (query string, arg queryBuilder.WriteString(" from ") // Table if c.search != "" { - queryBuilder.WriteString("posts_fts(@search)") + queryBuilder.WriteString("(select p.* from posts_fts(@search) ps, posts p where ps.path = p.path)") args = append(args, sql.Named("search", c.search)) } else { queryBuilder.WriteString("posts")