The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

news - a web fron-end to a local news server

SYNOPSIS

news

DESCRIPTION

news connects to the local news server via NNTP on port 119 and offers a web interface for it.

For each group, only the most recent posts are shown. The From field is stripped of things that look like email addresses such as \s*<.*> and \s*"\S+@\S+".

For each article, an attempt is made to strip email addresses, too. Detecting email addresses could be better, for sure.

Authentication

When posting or replying, the username and password provided by the user are passed along to the news server. If that allows the user to post, it just works.

Environment variables

The news server is determined by Net::NNTP: If no host is passed then two environment variables are checked NNTPSERVER then NEWSHOST, then Net::Config is checked, and if a host is not found then news is used.

NEWS_INTRO_ID can be set to a message id for a "start here" message. By default, no such link is shown. This must be a message-id and cannot be a message number (that would require a group, too).

NEWS_MODE can be set to "NOAUTH" in order to hide username and password on the post form in case your newsserver isn't public and requires no authorisation; if set to "NOPOST" then posting links are hidden.

Systemd

To install as a service, use a news.service file like the following:

    [Unit]
    Description=News (a web front-end)
    After=network-online.target
    Wants=network-online.target
    [Install]
    WantedBy=multi-user.target
    [Service]
    Type=simple
    DynamicUser=true
    Restart=always
    MemoryHigh=80M
    MemoryMax=100M
    Environment="NNTPSERVER=localhost"
    Environment="NEWS_INTRO_ID=<u4d0i0$n72d$1@sibirocobombus.campaignwiki>"
    ExecStart=/home/alex/perl5/perlbrew/perls/perl-5.32.0/bin/perl /home/alex/perl5/perlbrew/perls/perl-5.32.0/bin/news daemon

Cookies

The web app stores name, username and password in an encrypted cookie which expires one week after posting an article.

Caching

The web app caches all the data it gets from the news server in a cache, using Mojo::Cache. By default, this cache is small (100 items). Each cached item is cached with a timestamp and cache hits are only used if they aren't older than 5min.

EXAMPLES

The local news server requires no authorisation.

    NNTPSERVER=localhost NEWS_MODE=NOAUTH news daemon

As a developer, run it under morbo so that we can make changes to the script. Provide the path to the script. This time with regular authorisation.

    NNTPSERVER=localhost morbo script/news

The remote news server requires authorisation and we want to point visitors to a first post. We assume that NNTPSERVER or NEWSHOST is set.

    NEWS_INTRO_ID='<u4d0i0$n72d$1@sibirocobombus.campaignwiki>' news daemon

SEE ALSO

The Tildeverse also runs news. https://news.tildeverse.org/

LICENSE

GNU Affero General Public License