mastodon – matoken's blog https://matoken.org/blog Is there no plan B? Thu, 15 May 2025 11:47:08 +0000 ja hourly 1 https://wordpress.org/?v=6.9 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg mastodon – matoken's blog https://matoken.org/blog 32 32 Mastodonで任意の言語のトレンドを取得したい https://matoken.org/blog/2025/05/15/i-want-to-get-trends-for-a-specific-language-with-mastodon/ https://matoken.org/blog/2025/05/15/i-want-to-get-trends-for-a-specific-language-with-mastodon/#respond Thu, 15 May 2025 11:47:06 +0000 https://matoken.org/blog/?p=4557

セルフホストダッシュボードアプリのGlanceが先日v0.8.0がリリース.大型アップデートされました.

新機能の一つにCommunity widgetsがあります.これにより各種のJSONで帰ってくるコンテンツをカスタムウィジットとして表示できそうです.v0.8.0リリース時点ですでに40以上公開されています.
設定はglanceのyamlに書くだけです.

この中のMastodonのトレンドを表示するものがありました.

手元のウェブブラウザだと日本語のコンテンツが表示されるのにこのウィジットだと英語のものになります.
次のAPIを利用しているようです.getなんかでlang=jaのように指定できると便利そうですが言語選択はなさそうです.

curlで叩くと英語に.

$ curl -s https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://arstechnica.com/tech-policy/2025/05/meta-is-making-users-who-opted-out-of-ai-training-opt-out-again-watchdog-says/",
    "title": "Meta is making users who opted out of AI training opt out again, watchdog says",
    "description": "EU users have less than two weeks to opt out of Meta’s AI training.",
    "language": "en",
    "type": "link",
    "author_name": "Ashley Belanger",
    "author_url": "https://arstechnica.com/author/ashleybelanger/",
    "provider_name": "Ars Technica",

Accept-Language で ja を指定すると日本語に

$ curl -s -H 'Accept-Language: ja' https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://www.cnn.co.jp/fringe/35232941.html",
    "title": "長時間勤務で脳の構造が変化、認知や感情制御に影響も 韓国調査",
    "description": "長時間勤務が続くと脳の構造が変化して、認知機能や感情制御に影響を及ぼす恐れがあるという研究結果が、13日の医学誌に発表された。働き過ぎると身体的、精神的な無理が重なり、休養不足も加わって脳に
  重大な変化」が起きると指摘している。",
    "language": "ja",
    "type": "link",
    "author_name": "翻訳:CNN.co.jp編集部",
    "author_url": "",
    "provider_name": "CNN.co.jp",

Accept-Language で fr を指定するとフランス語になりました.

$ curl -s -H 'Accept-Language: fr' https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://www.huffingtonpost.fr/justice/article/la-justice-prend-une-decision-inedite-pour-une-personne-trans-en-france_250035.html",
    "title": "La justice prend une décision « inédite » pour une personne trans en France",
    "description": "Un homme trans, qui contestait en justice le refus de CPAM du Bas-Rhin de prendre en charge sa mastectomie, a obtenu gain de cause au tribunal de Strasbourg.",
    "language": "fr",
    "type": "link",
    "author_name": "Éva Craine",
    "author_url": "https://www.huffingtonpost.fr/author/eva-craine",
    "provider_name": "Le HuffPost",

ということでこのあたりを見て判断していそうです.Glance側で日本語を表示するには本体のsourceを修正しないといけなさそうです.

]]>
https://matoken.org/blog/2025/05/15/i-want-to-get-trends-for-a-specific-language-with-mastodon/feed/ 0
nanotodon 0.5.0でSixel https://matoken.org/blog/2025/01/12/nanotodon-0-5-0/ https://matoken.org/blog/2025/01/12/nanotodon-0-5-0/#respond Sat, 11 Jan 2025 22:03:50 +0000 https://matoken.org/blog/?p=4365

CLI Mastodon clientのnanotodon 0.5.0がリリースされました.
Sixel対応のようです.

  • Sixelがある程度動くようになった

Sixelのつかいかた

Makefileを見てね!

ということでReleaseからsource archiveを入手したり,git cloneしてMakefileを見てみます.

$ wget2 -c -v https://github.com/taka-tuos/nanotodon/archive/refs/tags/0.5.0.tar.gz
$ tar tvf 0.5.0.tar.gz
$ cd nanotodon-0.5.0

or

$ git clone https://github.com/taka-tuos/nanotodon
$ cd nanotodon
$ git checkout -b 0.5.0

Sixel対応のため以下のように編集しました.(Webpはオプション)

$ git diff Makefile
diff --git a/Makefile b/Makefile
index 6332820..238c2ed 100644
--- a/Makefile
+++ b/Makefile
@@ -10,11 +10,11 @@ LDLIBS += -lcurl -lpthread -lm
 CFLAGS += -DSUPPORT_XDG_BASE_DIR

 # EXPERIMENTAL: sixel support
-#CFLAGS += -DUSE_SIXEL
+CFLAGS += -DUSE_SIXEL

 # EXPERIMENTAL: webp support
-#CFLAGS += -DUSE_WEBP
-#LDLIBS += -lwebp
+CFLAGS += -DUSE_WEBP
+LDLIBS += -lwebp

 # for pkgsrc
 #CFLAGS += -I/usr/pkg/include
Note

webpを無効にするとwebp形式の画像の表示に失敗します.画像は以下のものに差し替えられました.結構webpは多いので有効にしたほうが良さそうです.

err

View on Mastodon

buildします.

$ make

そしてnanotodonを実行.

$ ./nanotodon

アイコンや添付画像がSixelで表示されるようになりました :)

nanotodon sixel

Sixel対応端末については以下のページが参考になります.

今回はmltermの上でtmuxを動かし,その上でnanotodonを動かしました.
以下はtmuxの上の窓でnanotodon,下の窓でsayakaでMisskeyを表示しています.

nanotodonsayaka

楽しいです :)

環境
$ dpkg-query -W make gcc libcurl4t64 libblis64-4-pthread
gcc     4:14.2.0-1
libblis64-4-pthread:amd64       1.0-1+b1
libcurl4t64:amd64       8.11.1-1
make    4.4.1-1
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/01/12/nanotodon-0-5-0/feed/ 0
terminalで動作するMastodon clientのnanotodonを試してみた https://matoken.org/blog/2018/05/21/try-terminal-base-masodon-client-nanotodon/ https://matoken.org/blog/2018/05/21/try-terminal-base-masodon-client-nanotodon/#respond Mon, 21 May 2018 11:15:51 +0000 http://matoken.org/blog/?p=1891 mikutodonをDebian jessie armhfに入れてみた.Makefileを修正したら動いたけど文字化けする.ちなみにDebian sid amd64では問題なく動作した.

$ cat /etc/debian_version 
8.10
$ uname -m
armv7l

ライブラリ等導入

$ sudo apt install build-essential libcurl4-openssl-dev libjson-c-dev libncurses-dev libncursesw5
$ dpkg-query -W build-essential libcurl4-openssl-dev libjson-c-dev libncurses-dev libncursesw5
build-essential 11.7
libcurl4-openssl-dev:armhf      7.38.0-4+deb8u11
libjson-c-dev:armhf     0.11-4
libncurses-dev  
libncursesw5:armhf      5.9+20140913-1+deb8u2

<追記>
入ってない場合gitも必要ですね $ sudo apt install git
</追記>

source入手

$ git clone https://github.com/taka-tuos/nanotodon

make

コケた

$ cd nanotodon
$ make
make -r nanotodon
make[1]: Entering directory '/home/chip/src/nanotodon'
gcc -c -g -o nanotodon.o nanotodon.c
nanotodon.c: In function 'stream_event_notify':
nanotodon.c:110:12: warning: initialization discards 'const' qualifier from pointer target type
  char *t = json_object_get_string(notify_type);
            ^
nanotodon.c: At top level:
nanotodon.c:138:6: warning: conflicting types for 'stream_event_update'
 void stream_event_update(struct json_object *jobj_from_string)
      ^
nanotodon.c:128:3: note: previous implicit declaration of 'stream_event_update' was here
   stream_event_update(status);
   ^
nanotodon.c: In function 'stream_event_update':
nanotodon.c:180:14: warning: initialization discards 'const' qualifier from pointer target type
  char *src = json_object_get_string(content);
              ^
nanotodon.c:226:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (int i = 0; i < json_object_array_length(media_attachments); ++i) {
   ^
nanotodon.c:226:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
nanotodon.c:245:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for(int i = 0; i < term_w - (l + 4); i++) waddstr(scr, " ");
   ^
nanotodon.c: At top level:
nanotodon.c:589:6: warning: conflicting types for 'do_htl'
 void do_htl()
      ^
nanotodon.c:303:2: note: previous implicit declaration of 'do_htl' was here
  do_htl();
  ^
nanotodon.c: In function 'do_htl':
nanotodon.c:618:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for (int i = json_object_array_length(jobj_from_string) - 1; i >= 0; i--) {
   ^
nanotodon.c: In function 'main':
nanotodon.c:751:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
  for(int i = 0; i < term_w; i++) mvaddch(5, i, '-');
  ^
nanotodon.c:777:4: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    for(int i = 0; i < term_w; i++) mvaddch(5, i, '-');
    ^
nanotodon.c:802:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   for(int i = 0; i < txt.stringlen; i++) {
   ^
Makefile.in:21: recipe for target 'nanotodon.o' failed
make[1]: *** [nanotodon.o] Error 1
make[1]: Leaving directory '/home/chip/src/nanotodon'
Makefile.in:11: recipe for target 'default' failed
make: *** [default] Error 2

Makefileを修正したら通った

diff --git a/Makefile b/Makefile
index ac1828f..a35ee6a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 TARGET         = nanotodon
 OBJS_TARGET    = nanotodon.o
 
-CFLAGS = -g
+CFLAGS = -g -std=gnu99
 LDFLAGS = 
 LIBS = -lc -lm -lcurl -ljson-c -lncursesw -lpthread
 

文字化け><

20180521_20:05:50-30304

Debian sid amd64ではMakefileの書き換えも必要なく文字化けもしない.

20180521_20:05:01-31796

$ cat /etc/debian_version 
buster/sid
$ uname -m
x86_64
$ dpkg-query -W build-essential libcurl4-openssl-dev libjson-c-dev libncurses-dev libncursesw5
build-essential 12.5
libcurl4-openssl-dev:amd64      7.60.0-1
libjson-c-dev:amd64     0.12.1-1.3
libncurses-dev:amd64    6.1+20180210-3
libncursesw5:amd64      6.1+20180210-3
]]>
https://matoken.org/blog/2018/05/21/try-terminal-base-masodon-client-nanotodon/feed/ 0