Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 82 lines (59 sloc) 1.68 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/bin/bash

DIR="$1"
DOWNLOAD="$2"

if [ -z "$DIR" ]; then
echo 'Usage: gen.sh DATA_DIR DOWNLOAD'
echo ''
echo ' DATA_DIR ... path to data directory'
echo ' DOWNLOAD ... 1 (do download with wget) or 0 (use already downloaded files)'
echo ''
echo 'Example:'
echo ' ./gen.sh data 1'
echo ''
exit
fi

if [ ! -d "$DIR" ]; then
echo "Directory '$DIR' not found."
exit;
fi

if [ -z "$DOWNLOAD" ]; then
echo "No download parameter not specified."
exit;
fi


echo "<html>"
echo "<head>"
echo "<title>Perl 6 and Parrot links statistics</title>"
echo "</head>"
echo "<body>"

echo "<br />"
echo '<a href="http://perl6.cz/wiki/Perl_6_and_Parrot_links">Perl 6 and Parrot links</a> statistics'

echo "<pre>"

DATE=`date`
echo "Date: $DATE"
echo " "

YEARS="2012 2011 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000"
SECTION=2

for YEAR in ${YEARS}; do

INPUT_FILE="${DIR}/links${YEAR}.wiki"
OUTPUT_FILE="${DIR}/links${YEAR}-filtered.wiki"
DIFF_FILE="${DIR}/links${YEAR}-diff.txt"
YEAR_URL="http://perl6.cz/w/index.php?title=Perl_6_and_Parrot_links&action=raw&section=$SECTION"

if [ "$DOWNLOAD" == "1" ]; then
echo "Downloading $YEAR (section <a href=\"${YEAR_URL}\">$SECTION</a>)"
wget -q -O $INPUT_FILE "${YEAR_URL}"
((SECTION = SECTION + 1))
fi


perl filter.pl $INPUT_FILE > $OUTPUT_FILE

diff --text -y $OUTPUT_FILE $INPUT_FILE > $DIFF_FILE

echo "Year $YEAR:"

echo -n " links: "
cat $OUTPUT_FILE | wc -l

echo -n " all lines: "
cat $INPUT_FILE | wc -l

echo " "
done

echo "</pre>"

echo '<a href="./data">Data</a><br>'
echo '<a href="https://github.com/mj41/P6aP-links-stat">Source code on GitHub</a><br>'

echo "</body>"
echo "</html>"
Something went wrong with that request. Please try again.