News­Mag 2k

Generate nice ansi themed BBS news from a simple textfile

Features

  • Themeable
    Add your own ansi or use defaults.
  • Cropable
    Only display latest X news without losing older ones.
  • UTF8 + CP437
    Can output oldschool cp437 ansi and utf-8 encoded files.

Prequisites

  • Perl
  • Perl libs:
    • utf8
    • Text::Wrap
    • Encode
    • Getopt::Long
    • Data::Dumper

Installation

None required. Simply run newsmag.pl or newsmag.pl -h for help.

Usage

usage: newsmag.pl [options] --filehdr=newshdr.ans Header template --fileftr=newsftr.ans Footer template --fileentry=entryhdr.ans Entries template --infile=news.txt Input text-file --outfile=news.ans Output ansi-file --encoding=CP437 Output file encoding --num=0 Only display <num> entries (0=all) -p | --print Print output to STDOUT -q | --quiet Be quiet (overrides -p) -h | --help Print this help --longhelp Print more detailed help

By default, newsmag searches for the input text-file and all templates at the directory, you're in while running the script, but you can provide alternative paths and filenames for everything. Check newsmag.pl -h for a list of all available options and their default values.

Input file

Default:
./news.txt Parameter:
--infile=/path/to/your/news.txt

You write news in this file using this simple format:

<DATE> <SUBJECT> <CONTENT> <MORE CONTENT> <...> @NEXT@ <DATE> <SUBJECT> <CONTENT>

Order doesn't matter, NewsMag always sorts the input by date, newest first.

Templates

NewsMag comes with some template examples, you are free to use. But you can also create your own using the examples and/or this description:

Header:

default:
./newshdr.ans parameter:
--filehdr=/path/to/your/headertemplate.ans

This file holds your header template to be displayed above all the news. It has no special variables (yet)..

Footer:

default:
./newsftr.ans parameter:
--fileftr=/path/to/your/footertemplate.ans

This file holds your footer template to be displayed beneath all the news. It can hold one special variable: @COPYRIGHT@ - Will be replaced by a short copyright notice. If omitted the notice will be auto-appended below the footer.

Entries:

default:
./entryhdr.ans parameter:
--fileentry=/path/to/your/entrytemplate.ans

This file holds your entry-template used to display each news entry. It must hold three special variables:

@DATE@ Will be replaced by the first line of your entries at news.txt

@SUBJECT@ Will be replaced by the second line of your entries at news.txt

@CONTENT@ Will be replaced by all the lines between the second and the next one containing the tag "@NEXT@" (See section "INPUT FILE") Also takes all characters to the left and repeats them on subsequent lines.

Padding:
You can pad these variables to fit into your template files by appending <length><direction>@.
e.g:

@DATE@16L@ This will pad the date to 16 characters by adding whitespace to the left.

@SUBJECT@32R@ This will pad the subject to 32 characters by adding whitespace to the right.

Wrapping:
Content lines are wrapped to 75 characters by default. Also, all characters to the left of the @CONTENT@ tag in your template.ans are repeated on subsequent lines.
You can change the line width by adding <width>@ to the variable.
e.g:

@SUBJECT@70@ This will wrap lines at 70 characters.

If any of these template files are omitted or not found, NewsMag will use very simple, hardcoded defaults.

OUTPUT

default:
./news.ans parameter:
--outfile=/path/to/your/outputfile.ans

Using all these different input files, NewsMag creates one huge ansi-file containing all news entries from your news.txt. You can limit the news to be displayed with the option --num=<num>

BBS CONFIGURATION

Some BBS systems automaticaly display files called "news.ans" at the login process if they have changed since the users last visit. some other systems have to be configured that way.

MysticBBS

For MysticBBS, I've attached a small .mps script you can include into your "prelogin" menu with the name of your news.ans inside the text directory of your MysticBBS theme:

  • (E)dit -> (M)enu Editor -> default (or your template) -> prelogin
  • Press enter to edit the first entry called FIRSTCMD
  • Press tab to edit the commands
  • Navigate to a position in your login process, you'ld like the news to be displayed
  • Press /, then i to insert a new command
  • Select (C)ommand: (GX) Execute MPL program
  • Add (D)ata: newsmag news
  • Exit and save.

Now, users will see the news.ans inside the "text-directory" of your BBS (default: /mystic/text) everytime they log in and the file has changed since their last login.

At the moment, the attached .mps is simply the onlyonce.mps, which comes with MysticBBS, but with a "Pause Prompt" at the end. Probably, I'll enhance it later..

License

Copyright (C) 2018 Philipp Giebel stimpy <ÄT> kuehlbox.wtf

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 the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Download

Download v0.1.1

Download latest alpha

git clone https://gitlab.ambhost.net/scripts/newsmag.git