Talk:Fanfic
From Betamountain.org
How This Page Works
Due to the large number of elements, this page is built on information from this Google spreadsheet.
Content adds\edits\etc are made to the spreadsheet and then downloaded as a CSV.
The CSV is pulled through a Perl script and formatted for the page information, then posted. There should be no direct edits to the page itself, only exports from the Perl output.
Perl Example
Example code
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Text::CSV; my $filename='temp.txt'; my $NAME_CHECK=""; my $COUNTER=0; my $INPUT_FILE = $ARGV[0] or die "Need to get CSV file on the command line\n"; my $CSV = Text::CSV->new ({ binary => 1, auto_diag => 1, sep_char => ',' # not really needed as this is the default } ); open(my $DATA_IN, '<:encoding(utf8)', $INPUT_FILE) or die "Could not open '$INPUT_FILE' $!\n"; open (my $DATA_OUT, '>:encoding(utf8)', "output.txt") or die "Could not open: $!\n"; SETUP (); while (my $fields = $CSV->getline( $DATA_IN )) { ##1 #2 Title Author PERM Done? BM FF AO3 . Other1 . RATING LANGUAGE STYLE Chapter # Length Published Updated Description my $skip_1; my $SORT; my $TITLE; my $AUTHOR; my $PERMISSION; my $DONE; my $BM; my $FANFIC; my $AO3; my $OTHER; my $RATING; my $LANGUAGE; my $STYLE; my $CHAPTERS; my $LENGTH; my $PUBLISHED; my $UPDATED; my $DESC; my $NOTES; my $SHADE; #### $skip_1 = $fields->[0]; $SORT = $fields->[1]; $TITLE = $fields->[2]; $AUTHOR = $fields->[3]; $PERMISSION = $fields->[4]; $DONE = $fields->[5]; $BM = $fields->[6]; $FANFIC = $fields->[7]; $AO3 = $fields->[9]; $OTHER = $fields->[11]; $RATING = $fields->[13]; $LANGUAGE = $fields->[14]; $STYLE = $fields->[15]; $CHAPTERS = $fields->[16]; $LENGTH = $fields->[17]; $PUBLISHED = $fields->[18]; $UPDATED = $fields->[19]; $DESC = $fields->[20]; $NOTES = $fields->[21]; #### ############# #close $fh; #$filename = "output/$NAME-bio.txt"; #open(my $fh, '>', $filename) or die "Could not open file '$filename' $!"; ############# if ($skip_1=~ "X") { } else { $COUNTER++; if (0 == $COUNTER % 2) { # print "The number $COUNTER is even\n"; # There is no remainder $SHADE="style=\"background:#D3D3D3\""; #print "$SHADE\n"; } else { #print "The number $COUNTER is odd\n"; # There is a remainder (of 1) $SHADE=""; #print "$SHADE\n"; } #print "SKIP: $skip_1\n"; #print $DATA_OUT "| $SORT\n"; #print $DATA_OUT "| $TITLE\n"; #print $DATA_OUT "| {{#ifexist: $TITLE | [[$TITLE]] | $TITLE }} \n"; if ($DONE =~ "N") { print $DATA_OUT "|$SHADE|$TITLE\n"; } else { print $DATA_OUT "|$SHADE|[[$TITLE]]\n"; #print $DATA_OUT "|\n"; } print $DATA_OUT "|$SHADE|$AUTHOR\n"; #print "PERMISSION: $PERMISSION\n"; #print "DONE: $DONE\n"; #print $DATA_OUT "|[[$TITLE]]\n"; if ($FANFIC=~ "^http(.*)") { print $DATA_OUT "|$SHADE|[$FANFIC FF]\n"; } else { print $DATA_OUT "|$SHADE|\n"; } if ($AO3=~ "^http(.*)") { print $DATA_OUT "|$SHADE|[$AO3 Ao3 ]\n"; } else { print $DATA_OUT "|$SHADE|\n"; } if ($OTHER=~ "^http(.*)") { print $DATA_OUT "|$SHADE|[$OTHER Site]\n"; } else { print $DATA_OUT "|$SHADE|\n"; } print $DATA_OUT "|$SHADE|$RATING\n"; #print $DATA_OUT "| $LANGUAGE\n"; #print $DATA_OUT "| $STYLE\n"; #print $DATA_OUT "| $CHAPTERS\n"; print $DATA_OUT "|$SHADE|$LENGTH\n"; print $DATA_OUT "|$SHADE|$PUBLISHED\n"; #print "UPDATED: $UPDATED\n"; #print "DESC: $DESC\n"; #print "NOTES: $NOTES\n"; print $DATA_OUT "|-\n"; print "-----------------------------------\n\n"; } ######## $skip_1=""; $SORT=""; $TITLE=""; $AUTHOR=""; $PERMISSION=""; $DONE=""; $BM=""; $FANFIC=""; $AO3=""; $OTHER=""; $RATING=""; $LANGUAGE=""; $STYLE=""; $CHAPTERS=""; $LENGTH=""; $PUBLISHED=""; $UPDATED=""; $DESC=""; $NOTES=""; #### } if (not $CSV->eof) { $CSV->error_diag(); } close $DATA_IN; print $DATA_OUT "|}\n"; close $DATA_OUT; sub CATEGORY { my $in=shift; if (defined $in && length $in > 0) { #print $fh "[[Category:$in]]\n"; } } sub BOX_OUTPUT { my ($type, $val) = @_; if (defined $val && length $val > 0) { print "$type: $val\n"; } } sub SETUP { print $DATA_OUT "See Also [[:Category:Fanfic]]\n\n"; print $DATA_OUT "'''''Note:''' This page is under construction and there are parts missing from the list (apologies to AKK)!.''\n\n"; print $DATA_OUT "{| class=\"wikitable sortable\" style=\"margin: 1ex auto 1ex auto\"\n"; # print $DATA_OUT "! Sort\n"; print $DATA_OUT "! Title\n"; print $DATA_OUT "! Author\n"; #print $DATA_OUT "! BM\n"; print $DATA_OUT "! FF\n"; print $DATA_OUT "! AO3\n"; print $DATA_OUT "! Site\n"; print $DATA_OUT "! Rating\n"; #print $DATA_OUT "! Language\n"; #print $DATA_OUT "! Style\n"; #print $DATA_OUT "! Chapters\n"; print $DATA_OUT "! Length\n"; print $DATA_OUT "! Published\n"; print $DATA_OUT "|-\n"; }