Home
DevCentral
Search
Configure Global Search
Log In
Transactions
P11
Change Details
Change Details
Old
New
Diff
#!/bin/sh # # Nasqueron Tools helper script # # Handles a new site on wikimedia/write/sourcetemplatesgenerator # # Usage: new-site-in-source-templates-generator http://www.domain.tld/ ClassNameForDomain # BASE=/home/dereckson/dev/nasqueron/tools DIR=$BASE/packages/source-templates-generator TEMPLATE=$BASE/support/ClassExtendingPage.tmpl INDEX=$DIR/pages/index.dat EDITOR=nano # Helper function uppers=ABCDEFGHIJKLMNOPQRSTUVWXYZ lowers=abcdefghijklmnopqrstuvwxyz strtolower () { # -- technosaurus, http://stackoverflow.com/a/8952274/1930997 i=0 while ([ $i -lt ${#1} ]) do CUR=${1:$i:1} case $uppers in *$CUR*)CUR=${uppers%$CUR*};OUTPUT="${OUTPUT}${lowers:${#CUR}:1}";; *)OUTPUT="${OUTPUT}$CUR";; esac i=$((i+1)) done echo "${OUTPUT}" } # Checks arguments if [ $# -eq 2 ]; then if [ $(echo $1 | grep -E "^https?://.*?/$") ]; then URL=$1 else echo "Not a valid URL: $1" echo "Expected format: http://www.domain.tld/" exit 2 fi CLASS=$2 CLASSFILE=$DIR/pages/`echo $CLASS | tr [A-Z] [a-z]`.php else echo "Usage: $0 http://www.domain.tld/ ClassNameForDomain" exit 1 fi # Generates content #Creates the class file from template cat $TEMPLATE | sed "s/%%class%%/$CLASS/g" | sed "s!%%url%%!$URL!g" > $CLASSFILE #Adds the class to index.dat printf "%s\t%s" $URL $CLASS >> $INDEX sort $INDEX -o $INDEX #Launches editor, then shows the Git state of the repository $EDITOR $CLASSFILE cd $DIR git status
#!/bin/sh # # Nasqueron Tools helper script # # Handles a new site on wikimedia/write/sourcetemplatesgenerator # # Usage: new-site-in-source-templates-generator http://www.domain.tld/ ClassNameForDomain # BASE=/home/dereckson/dev/nasqueron/tools DIR=$BASE/packages/source-templates-generator TEMPLATE=$BASE/support/ClassExtendingPage.tmpl INDEX=$DIR/pages/index.dat EDITOR=nano # Helper function uppers=ABCDEFGHIJKLMNOPQRSTUVWXYZ lowers=abcdefghijklmnopqrstuvwxyz strtolower () { # -- technosaurus, http://stackoverflow.com/a/8952274/1930997 i=0 while ([ $i -lt ${#1} ]) do CUR=${1:$i:1} case $uppers in *$CUR*)CUR=${uppers%$CUR*};OUTPUT="${OUTPUT}${lowers:${#CUR}:1}";; *)OUTPUT="${OUTPUT}$CUR";; esac i=$((i+1)) done echo "${OUTPUT}" } # Checks arguments if [ $# -eq 2 ]; then if [ $(echo $1 | grep -E "^https?://.*?/$") ]; then URL=$1 else echo "Not a valid URL: $1" echo "Expected format: http://www.domain.tld/" exit 2 fi CLASS=$2 CLASSFILE=$DIR/pages/`echo $CLASS | tr [A-Z] [a-z]`.php else echo "Usage: $0 http://www.domain.tld/ ClassNameForDomain" exit 1 fi # Generates content #Creates the class file from template cat $TEMPLATE | sed "s/%%class%%/$CLASS/g" | sed "s!%%url%%!$URL!g" > $CLASSFILE #Adds the class to index.dat printf "%s\t%s" $URL $CLASS >> $INDEX sort $INDEX -o $INDEX #Launches editor, then shows the Git state of the repository $EDITOR $CLASSFILE cd $DIR git status
Continue