Page MenuHomeDevCentral

new-site-in-source-templates-generator
ActivePublic

Authored by dereckson on Nov 23 2014, 21:27.
#!/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
# 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

Event Timeline

dereckson changed the title of this paste from untitled to new-site-in-source-templates-generator.
dereckson updated the paste's language from autodetect to autodetect.
dereckson updated the paste's language from autodetect to bash.Nov 23 2014, 21:28
dereckson changed the visibility from "All Users" to "Public (No Login Required)".
dereckson added a project: Nasqueron Tools.
dereckson edited the content of this paste. (Show Details)