From 1ba5d4e4441aae9a4f1d7a539fdea36a71788e26 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 31 Jan 2019 18:01:15 +0100 Subject: [PATCH] Added manpage --- .drone.yml | 6 +-- CMakeLists.txt | 13 +++++++ README.md | 50 +++++-------------------- build_manpage.sh | 12 ++++++ expandurl-mastodon.1.adoc | 79 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 43 deletions(-) create mode 100755 build_manpage.sh create mode 100644 expandurl-mastodon.1.adoc diff --git a/.drone.yml b/.drone.yml index 56a9521..de5c4ed 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,7 @@ pipeline: - echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list - apt-get update -q - apt-get install -qy build-essential cmake pkg-config - - apt-get install -qy libjsoncpp-dev libcurl4-openssl-dev libxdg-basedir-dev + - apt-get install -qy libjsoncpp-dev libcurl4-openssl-dev libxdg-basedir-dev asciidoc - apt-get install -qy -t sid libcurlpp-dev - dpkg -i mastodon-cpp.deb - rm -rf build && mkdir -p build && cd build @@ -43,7 +43,7 @@ pipeline: - apt-get update -q - apt-get install -qy build-essential cmake pkg-config - apt-get install -qy -t xenial g++-7 - - apt-get install -qy libjsoncpp-dev libcurl4-openssl-dev libxdg-basedir-dev + - apt-get install -qy libjsoncpp-dev libcurl4-openssl-dev libxdg-basedir-dev asciidoc - apt-get install -qy -t sid libcurlpp-dev - dpkg -i mastodon-cpp.deb - rm -rf build && mkdir -p build && cd build @@ -69,7 +69,7 @@ pipeline: - apt-get update -q - apt-get install -qy build-essential cmake pkg-config - apt-get install -qy -t xenial g++-8 - - apt-get install -qy libjsoncpp-dev libcurl4-openssl-dev libxdg-basedir-dev + - apt-get install -qy libjsoncpp-dev libcurl4-openssl-dev libxdg-basedir-dev asciidoc - apt-get install -qy -t sid libcurlpp-dev - dpkg -i mastodon-cpp.deb - rm -rf build && mkdir -p build && cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fee29a..3acb470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,16 @@ target_link_libraries(expandurl-mastodon ${CURLPP_LIBRARIES} ${JSONCPP_LIBRARIES} ${LIBXDG_BASEDIR_LIBRARIES} mastodon-cpp pthread stdc++fs) install(TARGETS expandurl-mastodon DESTINATION ${CMAKE_INSTALL_BINDIR}) + +set(WITH_MAN "YES" CACHE STRING "WITH_MAN defaults to \"YES\"") +if (WITH_MANPAGE) + add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1" + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" + DEPENDS "${CMAKE_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.1.adoc" + COMMAND ${CMAKE_SOURCE_DIR}/build_manpage.sh + ARGS ${PROJECT_VERSION}) + add_custom_target(run ALL + DEPENDS "${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +endif() diff --git a/README.md b/README.md index 963d6e7..5afff3b 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,15 @@ or to [@tastytea@soc.ialis.me](https://soc.ialis.me/@tastytea). ## Dependencies - * Tested OS: Linux - * C++ compiler (tested: gcc 6/7/8) - * [cmake](https://cmake.org/) (tested: 3.9 / 3.11) - * [curlpp](http://www.curlpp.org/) (tested: 0.8) - * [mastodon-cpp](https://schlomp.space/tastytea/mastodon-cpp) (at least: 0.30) - * [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (tested: 1.8 / 1.7) - * [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2) +* Tested OS: Linux +* C++ compiler (tested: gcc 6/7/8) +* [cmake](https://cmake.org/) (tested: 3.9 / 3.11) +* [curlpp](http://www.curlpp.org/) (tested: 0.8) +* [mastodon-cpp](https://schlomp.space/tastytea/mastodon-cpp) (at least: 0.30) +* [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (tested: 1.8 / 1.7) +* [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2) +* Optional: + * Manpage: [asciidoc](http://asciidoc.org/) (tested: 8.6) ## Get sourcecode @@ -54,39 +56,7 @@ Install with `make install`. # Usage -**The config file has changed from cfg to JSON in 0.4.0.** - -Start expandurl-mastodon without parameters. - -If no config file is found, you will be asked to provide your account address -and an access token is generated. The config file can be found in -`${HOME}/.config/expandurl-mastodon.json` and looks like this: - -```JSON -{ - "account": "expandurl@example.social", - "access_token": "abc123", - "proxy": - { - "url": "socks5h://[::1]:1080/", - "user": "user23", - "password": "supersecure" - }, - "replace" : - { - "//amp\\." : "//", - "[\\?&]__twitter_impression=[^&]+" : "", - "[\\?&]utm_[^&]+" : "", - "[\\?&]wt_zmc=[^&]+" : "", - "[\\?&]wtmc=[^&]+" : "" - } -} -``` - -If you want to use a proxy or define your own replacements, you have to edit the -configuration file manually. After the configuration file is generated, you can -start expandurl-mastodon as -daemon. +Have a look at the [manpage](https://schlomp.space/tastytea/expandurl-mastodon/src/branch/master/expandurl-mastodon.1.adoc). # Copyright diff --git a/build_manpage.sh b/build_manpage.sh new file mode 100755 index 0000000..0a1787d --- /dev/null +++ b/build_manpage.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +name="expandurl-mastodon" + +if [ -n "${1}" ]; then + dir="$(dirname ${0})" + cp -vf "${dir}/${name}.1.adoc" . + sed -Ei "s/(Revision: +)[0-9]+\.[0-9]\.[0-9]/\1${1}/" "${name}.1.adoc" + a2x --doctype manpage --format manpage --no-xmllint "${name}.1.adoc" +else + echo "usage: ${0} VERSION" >&2 +fi diff --git a/expandurl-mastodon.1.adoc b/expandurl-mastodon.1.adoc new file mode 100644 index 0000000..574fc9a --- /dev/null +++ b/expandurl-mastodon.1.adoc @@ -0,0 +1,79 @@ += expandurl-mastodon(1) +:Author: tastytea +:Email: tastytea@tastytea.de +:Date: 2019-01-31 +:Revision: 0.0.0 +:man source: expandurl-mastodon +:man version: {revision} +:man manual: General Commands Manual + +== NAME + +expandurl-mastodon - Mastodon bot that expands shortened URLs. + +== SYNOPSIS + +*expandurl-mastodon* + +== DESCRIPTION + +If you want the bot to expand an URL, reply to the post with the URL in it and +mention the bot account. + +This bot uses the same visibility as you, but posts unlisted instead of public. +It retains the sensitive flag and spoiler warnings. + +Some tracking parameters, like those beginning with +https://en.wikipedia.org/wiki/UTM_parameters[utm_] are stripped. It also tries +to rewrite https://en.wikipedia.org/wiki/Accelerated_Mobile_Pages[AMP] URLs to +point at the real webpages. + +== CONFIGURATION + +If no config file is found, you will be asked to provide your account address +and an access token is generated. The config file can be found in +`${XDG_CONFIG_HOME}/expandurl-mastodon.json` and looks like this: + +[source,json] +---- +{ + "account": "expandurl@example.social", + "access_token": "abc123", + "proxy": + { + "url": "socks5h://[::1]:1080/", + "user": "user23", + "password": "supersecure" + }, + "replace" : + { + "//amp\\." : "//", + "[\\?&]__twitter_impression=[^&]+" : "", + "[\\?&]utm_[^&]+" : "", + "[\\?&]wt_zmc=[^&]+" : "", + "[\\?&]wtmc=[^&]+" : "" + } +} +---- + +If you want to use a proxy or define your own replacements, you have to edit the +configuration file manually. After the configuration file is generated, you can +start expandurl-mastodon as daemon. + +== FILES + +[format="csv",frame="none",grid="none",cols=">,<"] +|====== +Configuration file:,`${XDG_CONFIG_HOME}/expandurl-mastodon.json` +|====== + +`${XDG_CONFIG_HOME}` is usually `~/.config`. + +== REPORTING BUGS + +[format="csv",frame="none",grid="none",cols=">,<"] +|====== +Bugtracker:,https://schlomp.space/tastytea/expandurl-mastodon/issues +E-mail:,tastytea@tastytea.de +Fediverse:,https://soc.ialis.me/@tastytea +|======