From 293e3ffadbd0c297b5e2291c1f4c7d98625cd991 Mon Sep 17 00:00:00 2001 From: Harishankar Date: Fri, 22 May 2020 19:35:29 +0530 Subject: [PATCH] Made site template mobile friendly and added title to RSS feed Added the category/page title to the RSS feed and also made the site mobile template mobile friendly with CSS media queries and meta viewport --- biawebdocumenttree.hpp | 1 + biawebrss.hpp | 11 ++++++++++- templates/main.tpl.html | 1 + templates/rss.tpl.xml | 3 ++- templates/stringbits.txt | 4 ++-- templates/style.tpl.css | 27 +++++++++++++++++++++++++++ 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/biawebdocumenttree.hpp b/biawebdocumenttree.hpp index 447a5c7..5df2e9b 100644 --- a/biawebdocumenttree.hpp +++ b/biawebdocumenttree.hpp @@ -237,6 +237,7 @@ namespace biaweb { // rss feed std::unique_ptr feed (new RSSFeed ()); feed.get()->set_pub_date (index.get()->get_creation_date()); + feed.get()->set_title (this->get_title()); // iterate through the documents and generate the document for (Document doc : this->docs) { diff --git a/biawebrss.hpp b/biawebrss.hpp index eb4d0aa..61cee82 100644 --- a/biawebrss.hpp +++ b/biawebrss.hpp @@ -69,6 +69,7 @@ namespace biaweb { // class to implement an RSS feed class RSSFeed { protected: + std::string title; std::time_t pub_date; std::list items; public: @@ -80,6 +81,13 @@ namespace biaweb { // number of items std::size_t get_num_items () { return this->items.size (); + } + + std::string get_title () { + return this->title; + } + void set_title (std::string title) { + this->title = escape_html (title); } std::time_t get_pub_date() { @@ -103,7 +111,8 @@ namespace biaweb { std::string output = fmt::format (templ_str, fmt::arg ("pubdate", ct), - fmt::arg ("items", items_str) ); + fmt::arg ("items", items_str), + fmt::arg ("title", this->title)); std::ofstream f (path + "/feed.xml"); f << output; f.close (); diff --git a/templates/main.tpl.html b/templates/main.tpl.html index c57f20c..123729b 100644 --- a/templates/main.tpl.html +++ b/templates/main.tpl.html @@ -3,6 +3,7 @@ My Site - {title} + diff --git a/templates/rss.tpl.xml b/templates/rss.tpl.xml index d3d49ed..9cd3550 100644 --- a/templates/rss.tpl.xml +++ b/templates/rss.tpl.xml @@ -2,7 +2,8 @@ - My Site + + My Site - {title} Site Description http://my.site {pubdate:%a, %d %b %Y %H:%M:%S %z} diff --git a/templates/stringbits.txt b/templates/stringbits.txt index 774a7e0..01dbf75 100644 --- a/templates/stringbits.txt +++ b/templates/stringbits.txt @@ -2,7 +2,7 @@ Home List of Articles Index Page Navigation -Sub categories: +Sub categories of Go up -Subscribe +Subscribe to page RSS Feed \ No newline at end of file diff --git a/templates/style.tpl.css b/templates/style.tpl.css index ec2e68b..0abf5c6 100644 --- a/templates/style.tpl.css +++ b/templates/style.tpl.css @@ -77,3 +77,30 @@ section#content { line-height: 150%; text-align: justify; } +/* for small screens */ +@media only screen and (max-width: 600px) { + section#content { + width: 99%; + float: none; + margin-left: 0.5%; + margin-right: 0.5%; + text-align: left; + padding: 0; + } + img { + max-width: 100%; + height: auto; + } + header { + float: none; + } + footer { + float: none; + } + nav#sidebar { + float: none; + width: 99%; + margin-left: 0.5%; + margin-right: 0.5%; + } +} \ No newline at end of file -- 2.20.1