Compare commits

..

No commits in common. "main" and "0.13.0" have entirely different histories.
main ... 0.13.0

9 changed files with 21 additions and 76 deletions

View File

@ -8,21 +8,17 @@ endif()
# Global build options.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build.")
option(BUILD_SHARED_LIBS "Build shared libraries." YES) # Needed for boost.
option(BUILD_SHARED_LIBS "Build shared libraries." YES)
project (mastorss
VERSION 0.13.1
VERSION 0.13.0
DESCRIPTION "Another RSS to Mastodon bot."
LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
# Project build options.
option(WITH_MAN "Compile and install manpage." YES)
option(WITH_COMPLETIONS "Install Zsh completions." YES)
set(ZSH_COMPLETION_DIR "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions"
CACHE STRING "Installation directory for Zsh completions.")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -38,10 +34,6 @@ if(WITH_MAN)
add_subdirectory(man)
endif()
if(WITH_COMPLETIONS)
add_subdirectory(completions)
endif()
install(FILES watchwords.json
DESTINATION "${CMAKE_INSTALL_DATADIR}/mastorss")

View File

@ -16,22 +16,15 @@
*mastorss* reads RSS feeds and posts the items via the Mastodon API. Does not
support Atom at the moment.
== Usage
See link:{uri-branch-main}/man/mastorss.1.adoc[manpage].
== Install
[alt="Packaging status" link=https://repology.org/project/mastorss/versions]
image::https://repology.org/badge/vertical-allrepos/mastorss.svg[]
=== Gentoo
[source,shell]
--------------------------------------------------------------------------------
eselect repository enable guru
eselect repository enable tastytea
echo 'net-misc/mastorss' >> /etc/portage/package.accept_keywords/mastorss
emaint sync -r guru
emaint sync -r tastytea
emerge -a net-misc/mastorss
--------------------------------------------------------------------------------
@ -75,12 +68,10 @@ cmake ..
cmake --build .
--------------------------------------------------------------------------------
.CMake options:
* `-DCMAKE_BUILD_TYPE=Debug` Debug build.
* `-DWITH_MAN=NO` Don't install manpage.
* `-DWITH_COMPLETIONS=NO` Don't install completions.
* `-DZSH_COMPLETION_DIR` Change installation directory for Zsh completions.
Install with `make install`.
== Usage
See link:{uri-branch-main}/man/mastorss.1.adoc[manpage].
include::{uri-base}/raw/branch/main/CONTRIBUTING.adoc[]

View File

@ -1 +0,0 @@
install(FILES "_mastorss" DESTINATION "${ZSH_COMPLETION_DIR}")

View File

@ -1,26 +0,0 @@
# -*- mode: shell-script; -*-
#compdef mastorss
local context state state_descr line
typeset -A opt_args
_arguments \
"(- *)--dry-run[Do everything like normal, but don't post anything and don't update the config file.]" \
"(- *)--help[Show a short help message.]" \
"(- *)--version[Show version, copyright and license.]" \
"::Profile:->profiles"
case "$state" in
profiles)
# Find config dir.
local config_dir="${XDG_CONFIG_HOME}"
[[ -z "${config_dir}" ]] && config_dir="${HOME}/.config"
config_dir+="/mastorss"
# Extract profile names from config files.
for file in "${config_dir}"/config-*; do
profile="${file/*config-/}"
compadd ${profile%.json}
done
;;
esac

View File

@ -2,7 +2,7 @@
:doctype: manpage
:Author: tastytea
:Email: tastytea@tastytea.de
:Date: 2021-01-18
:Date: 2020-11-21
:Revision: 0.0.0
:man source: mastorss
:man manual: General Commands Manual
@ -28,7 +28,7 @@ file. The initial config file is still created, if the profile doesn't
exist. The interval between posts is set to 1 second.
*--help*::
Show a short help message.
Show help message.
*--version*::
Show version, copyright and license.
@ -67,9 +67,8 @@ This string will be appended to every post.
The URI of the source feed.
*fixes*::
Array of regular expressions that should be deleted from the text. Applies to
RSS descriptions (before the HTML is stripped). For information about the syntax
see *perlre*(1).
Array of regular expressions that should be deleted from the text. For
information about the syntax see *perlre*(1).
*instance*::
Hostname of the instance you're using to post.
@ -98,9 +97,9 @@ content warning) of the post.
If true, only post titles, no descriptions.
*replacements*::
Object with a list of regular expressions and replacements. Applies to posts
(after the HTML is stripped), subjects and links, but not to the string in
_append_. For information about the syntax see *perlre*(1).
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`.

View File

@ -1,5 +1,5 @@
/* This file is part of mastorss.
* Copyright © 2019-2021 tastytea <tastytea@tastytea.de>
* Copyright © 2019, 2020 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -233,12 +233,11 @@ void Document::parse_rss(const pt::ptree &tree)
}
}
string Document::remove_html(string html)
string Document::remove_html(string html) const
{
html = mastodonpp::unescape_html(html); // Decode HTML entities.
html = regex_replace(html, regex{"<p>"}, "\n\n");
html = regex_replace(html, regex{"<br>"}, "\n");
const list re_list{regex{R"(<!\[CDATA\[)"}, // CDATA beginning.
regex{R"(\]\]>)"}, // CDATA end.

View File

@ -1,5 +1,5 @@
/* This file is part of mastorss.
* Copyright © 2019-2021 tastytea <tastytea@tastytea.de>
* Copyright © 2019, 2020 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -84,7 +84,7 @@ private:
*/
void download(const string &uri, bool temp_redirect = false);
void parse_rss(const pt::ptree &tree);
[[nodiscard]] static string remove_html(string html);
[[nodiscard]] string remove_html(string html) const;
[[nodiscard]] static string
extract_location(const curl_wrapper::answer &answer);
string add_hashtags(const string &text);

View File

@ -15,7 +15,6 @@
*/
#include "config.hpp"
#include "curl_wrapper.hpp"
#include "document.hpp"
#include "exceptions.hpp"
#include "mastoapi.hpp"
@ -72,8 +71,7 @@ void print_version()
void print_help(const string_view command)
{
cerr << "Usage: " << command << " [--version|--help|--dry-run] <profile>\n"
<< "See manpage for details.\n";
cerr << "Usage: " << command << " [--version|--help] <profile>\n";
}
int run(const string_view profile_name, const bool dry_run)
@ -126,11 +124,6 @@ int run(const string_view profile_name, const bool dry_run)
cerr << e.what() << '\n';
return error::network;
}
catch (const curl_wrapper::CURLException &e)
{
cerr << e.what() << '\n';
return error::network;
}
catch (const Json::RuntimeError &e)
{
cerr << "JSON error:\n" << e.what() << '\n';

View File

@ -1,5 +1,5 @@
/* This file is part of mastorss.
* Copyright © 2019-2021 tastytea <tastytea@tastytea.de>
* Copyright © 2019, 2020 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -124,8 +124,6 @@ void MastoAPI::post_item(const Item &item, bool dry_run)
{
if (ret.http_status != 200)
{
BOOST_LOG_TRIVIAL(debug) << "Error message from server: "
<< ret.body;
throw HTTPException{ret.http_status};
}
throw CURLException{ret.curl_error_code};