diff --git a/man/mastorss.1.adoc b/man/mastorss.1.adoc index 3cbabab..0707c99 100644 --- a/man/mastorss.1.adoc +++ b/man/mastorss.1.adoc @@ -2,7 +2,7 @@ :doctype: manpage :Author: tastytea :Email: tastytea@tastytea.de -:Date: 2020-05-10 +:Date: 2020-10-29 :Revision: 0.0.0 :man source: mastorss :man manual: General Commands Manual @@ -32,8 +32,9 @@ Show version, copyright and license. Put `watchwords.json` into `${XDG_CONFIG_HOME}/mastorss/`. Launch with profile name. The first occurence of every watchword in an RSS item will be turned into -a hashtag. For profile-specific watchwords see the example in -`watchwords.json`. In the first run only the newest entry is posted. +a hashtag (unless *add_hashtags* is set to false). For profile-specific +watchwords see the example in `watchwords.json`. In the first run only the +newest entry is posted unless *keep_looking* is set to true. The profile is the identifier for a feed and can't be named "global". @@ -95,6 +96,9 @@ Object with a list of regular expressions and replacements. Applies to posts, subjects and links, but not to the string in _append_. For information about the syntax see *perlre*(1). +*add_hashtags*:: +If true, replace words with hashtags according to `watchwords.json`. + == EXAMPLES === Configuration file diff --git a/src/config.cpp b/src/config.cpp index c029efd..f448d37 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -91,7 +91,8 @@ std::ostream &operator<<(std::ostream &out, const ProfileData &data) out << ", "; } } - out << "]"; + out << "], "; + out << "add_hashtags: " << data.add_hashtags; return out; } @@ -194,6 +195,10 @@ void Config::generate() } profiledata.max_size = stoul(line); + cout << "Add hashtags according to watchwords.json? [y/n]: "; + std::getline(cin, line); + profiledata.add_hashtags = (line[0] == 'y'); + BOOST_LOG_TRIVIAL(debug) << "Generated configuration."; write(); } @@ -254,6 +259,7 @@ void Config::parse() profiledata.replacements.push_back( {search, _json[profile]["replacements"][search].asString()}); } + profiledata.add_hashtags = _json[profile]["add_hashtags"].asBool(); BOOST_LOG_TRIVIAL(debug) << "Read config: " << profiledata; } @@ -277,6 +283,7 @@ void Config::write() { _json[profile]["replacements"][replacement.first] = replacement.second; } + _json[profile]["add_hashtags"] = profiledata.add_hashtags; ofstream file{get_filename().c_str()}; if (file.good()) diff --git a/src/config.hpp b/src/config.hpp index 7aec47e..29a7d57 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -55,6 +55,7 @@ struct ProfileData bool titles_as_cw{false}; bool titles_only{false}; list> replacements; + bool add_hashtags{true}; friend std::ostream &operator<<(std::ostream &out, const ProfileData &data); }; diff --git a/src/document.cpp b/src/document.cpp index b21bb5d..f9f961d 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -213,7 +213,11 @@ void Document::parse_rss(const pt::ptree &tree) desc = regex_replace(desc, regex{fix}, ""); } desc = remove_html(desc); - return add_hashtags(desc); + if (_profiledata.add_hashtags) + { + desc = add_hashtags(desc); + } + return desc; }(); // clang-format on item.guid = move(guid);