paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9bbc8931fd2c608ea068d484003fcf8f01258465
parent 0c7007f009d342d1950c1a44643e6aed7f9c77b2
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sat,  4 Jul 2020 01:34:10 -0400

Remove gopherize, development in different repo

Diffstat:
Dgopherize | 89-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 89 deletions(-)

diff --git a/gopherize b/gopherize @@ -1,89 +0,0 @@ -#!/usr/bin/env perl - -# gopherize -# A script to convert an html document into gopher-compatible syntax -# -# Copyright (C) 2020 Jake Bauer -# -# 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 <https://www.gnu.org/licenses/>. - -use strict; -use warnings; -our $VERSION = "0.1.0"; - -use HTML::TreeBuilder; -use File::Basename; - -my $tree = HTML::TreeBuilder->new(); -my @files = @ARGV; -my $output_path="public/gopher"; -my $fh; - -# Prints links to the bottom of the page; -sub print_links { - my (@links) = @_; - print "Found ", scalar(@links), " links.\n"; - foreach my $link (@links) { - print "Link: ", $link->[0], ".\n"; - print "Obj: ", $link->[1], ".\n"; - print "Prop ", $link->[2], ".\n"; - print "Tag: ", $link->[3], ".\n"; - print "=========\n" - } - return; -} - -# Trims excess spaces from HTML::Strip output -sub trim { - my ($string) = @_; - $string =~ tr/ / /s; - return $string; -} - -# Create output directory -if (not -e $output_path and not -d $output_path) { - mkdir($output_path) or die "Could not mkdir $output_path: $!"; -} - -# Parse and gopherize each file -foreach my $file (@files) { - - my ($file_name, $dirs, $suffix) = fileparse($file, qr/\.[^.]*/); - - if (not $suffix =~ /html?/) { - warn "$file does not have .html or .htm extension, refusing to parse.\n"; - next; - } - - print "Opening input file: $file\n"; - open (my $orig_file, "<:encoding(UTF-8)", $file) - or do { - warn "Could not open input file $file: $!"; - next; - }; - - print "Creating output file: $output_path/$file_name.gph...\n"; - open($fh, ">", "$output_path/$file_name.gph") - or do { - warn "Could not open $output_path/$file_name.gph for writing: $!"; - next; - }; - - print "Parsing HTML from: $file...\n"; - $tree->parse_file($orig_file)->elementify(); - my $links_ref = $tree->extract_links("a", "img", "audio", "video"); - print_links(@$links_ref); - - close($fh); -}