App-phoebe
view release on metacpan or search on metacpan
script/phoebe-ctl view on Meta::CPAN
#!/usr/bin/env perl
# Copyright (C) 2017â2020 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero 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 Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
=encoding utf8
=head1 NAME
phoebe-ctl - Phoebe control
=head1 DESCRIPTION
This script helps you maintain your Phoebe installation.
=over
=item B<--wiki_dir=>I<DIR>
This the wiki data directory to use; the default is either the value of the
C<GEMINI_WIKI_DATA_DIR> environment variable, or the C<./wiki> subdirectory. Use
it to specify a space, too.
=item B<--log=>I<NUMBER>
This is the log level to use. 1 only prints errors; 2 also prints warnings (this
is the default); 3 prints any kind of information; 4 prints all sorts of info
the developer wanted to see as they were fixing bugs.
=back
=head2 Commands
B<phoebe-ctl help>
This is what you're reading right now.
B<phoebe-ctl update-changes>
This command looks at all the pages in the F<page> directory and generates new
entries for your changes log into F<changes.log>.
B<phoebe-ctl erase-page>
This command removes pages from the F<page> directory, removes all the kept
revisions in the F<keep> directory, and all the mentions in the F<change.log>.
Use this if spammers and vandals created page names you want to eliminate.
B<phoebe-ctl html-export> [B<--source=>F<subdirectory> ...]
[B<--target=>F<directory>] [B<--no-extension>]
This command converts all the pages in the subdirectories provided to HTML and
writes the HTML files into the target directory. The subdirectories must exist
inside your wiki data directory. The default wiki data directory is F<wiki> and
the default source subdirectory is undefined, so the actual files to be
processed are F<wiki/page/*.gmi>; if you're using virtual hosting, the
subdirectory might be your host name; if you're using spaces, those need to be
appended as well.
Example:
phoebe-ctl html-export --wiki_dir=/home/alex/phoebe \
--source=transjovian.org \
--source=transjovian.org/phoebe \
--source=transjovian.org/gemini \
--source=transjovian.org/titan \
--target=/home/alex/transjovian.org
This will create HTML files in F</home/alex/transjovian.org>,
F</home/alex/transjovian.org/phoebe>, F</home/alex/transjovian.org/gemini>, and
F</home/alex/transjovian.org/titan>.
Note that the I<links> in these HTML files do not include the F<.html> extension
(e.g. C</test>), so this relies on your web server doing the right thing: if a
visitor requests C</test> the web server must serve F</test.html>. If that
doesn't work, perhaps using C<--no-extension> is your best bet: the HTML files
will be written without the F<.html> extension. This should also work for local
browsing, although it does look strange, all those pages with the F<.html>
extension.
=cut
package Gemini::Wiki::Control;
use Modern::Perl '2018';
use File::Slurper qw(read_dir read_lines read_text write_text);
use Encode qw(encode_utf8 decode_utf8);
use Getopt::Long;
use Pod::Text;
use File::Path qw(remove_tree);
use utf8;
binmode(STDOUT, ":utf8");
my $log = 2;
my $dir = "./wiki";
my @sources;
my $target;
my $no_extension;
GetOptions (
"log=i" => \$log,
( run in 0.716 second using v1.01-cache-2.11-cpan-39bf76dae61 )