end
-- Header and footer
- if ishtml and file ~= fheader and file ~= ffooter then
+ if ishtml and file ~= fheader and file ~= ffooter and not string.match(file,'/tmpl/') then
local header = self:readall(fheader)
local footer = self:readall(ffooter)
content = header .. content .. footer
.. (content:sub(p2+1))
end
+ -- From request_uri
+ if not vars.title then
+ local basename = string.match(ngx.var.request_uri,'([^/]+)/?$')
+ if basename then
+ local noext = string.match(basename,'([^%.]*)')
+ vars.title = noext
+ end
+ end
+
-- From filename
-- if not vars.title then
-- vars.title = string.match(file,'([^/%.]+)%.') -- basename
-- end
-- end
- -- From request_uri
- if not vars.title then
- local basename = string.match(ngx.var.request_uri,'([^/]+)$')
- if basename then
- local noext = string.match(basename,'([^%.]+)')
- vars.title = noext
- end
- end
-
-- Default first tld domain
- if not vars.title then vars.title = string.match(ngx.var.http_host,'^([^%.]+)') end
+ -- if not vars.title then vars.title = string.match(ngx.var.http_host,'^([^%.]+)') end
content = self:html_fix(content)
template.render(content,vars)
--- /dev/null
+DROP TABLE IF EXISTS content;
+CREATE TABLE IF NOT EXISTS content (
+ -- id SERIAL PRIMARY KEY,
+ --id VARCHAR(500) PRIMARY KEY,
+ path VARCHAR(300),
+ file VARCHAR(100),
+ title VARCHAR(250) NOT NULL,
+ created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ -- type VARCHAR(100) NOT NULL,
+ content TEXT NOT NULL,
+ PRIMARY KEY(path,file)
+);
+
+CREATE INDEX IF NOT EXISTS content_created ON content USING btree (created);
+CREATE INDEX IF NOT EXISTS content_type ON content USING btree (type);
+CREATE INDEX IF NOT EXISTS content_title ON content USING btree (title);
+
+DROP FUNCTION IF EXISTS content_before_insert();
+/*
+*/
+CREATE FUNCTION content_before_insert() RETURNS trigger as 'BEGIN
+ NEW.updated = now();
+ RETURN NEW;
+END' LANGUAGE 'plpgsql';
+
+DROP TRIGGER IF EXISTS content_before_insert ON content;
+/*
+*/
+CREATE TRIGGER content_before_insert BEFORE INSERT OR UPDATE ON content
+FOR EACH ROW
+EXECUTE PROCEDURE content_before_insert()
+;
+
+COPY content (path, file, title, created, updated, content) FROM stdin;
+/ test1.html Test 2018-06-03 11:59:16 2018-06-03 12:59:35.702535 This is a test
+/ test2.html Test2 2018-06-03 11:59:39 2018-06-03 12:59:53.506176 Second text example
+/a test1.html Test 2018-06-03 11:59:16 2018-06-03 12:59:35.702535 This is a test
+/b test2.html Test2 2018-06-03 11:59:39 2018-06-03 12:59:53.506176 Second text example
+\.
+++ /dev/null
-DROP TABLE IF EXISTS content;
-CREATE TABLE IF NOT EXISTS content (
- id SERIAL PRIMARY KEY,
- type VARCHAR(250) NOT NULL,
- title VARCHAR(250) NOT NULL,
- created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- content TEXT NOT NULL
-);
-CREATE INDEX IF NOT EXISTS content_created ON content USING btree (created);
-CREATE INDEX IF NOT EXISTS content_type ON content USING btree (type);
-CREATE INDEX IF NOT EXISTS content_title ON content USING btree (title);
-
-DROP FUNCTION IF EXISTS content_before_insert();
-/*
-*/
-CREATE FUNCTION content_before_insert() RETURNS trigger as 'BEGIN
- NEW.updated = now();
- RETURN NEW;
-END' LANGUAGE 'plpgsql';
-
-DROP TRIGGER IF EXISTS content_before_insert ON content;
-/*
-*/
-CREATE TRIGGER content_before_insert BEFORE INSERT OR UPDATE ON content
-FOR EACH ROW
-EXECUTE PROCEDURE content_before_insert()
-;