Forum Import Tool
This tool is still in development and subject to change.
Installing the software
# ubforums2ubwiki.sh # Version 0.1 # Copyleft 2012 bodhi.zazen # Assistance from cortman, forestpiskie, and wildmanne39 # This program is distributed free under terms of the GNU General Public License (v. 3.0) # script converts Ubuntu forums (VBulletin syntax) posts to # Ubuntu wiki (moin moin markdown). # Designed to facilitate transcribing Tutorials and documentation # from Ubuntu forums to Ubuntu wiki. # Pages for import are listed at # https://help.ubuntu.com/community/Pages%20For%20Import # Sanity checks [[ -d "${HOME}/Documents/ubforums2ubwiki" ]] || mkdir -p $HOME/Documents/ubforums2ubwiki #echo "This script calls the converter program and will create a converted file." #echo "First we'll confirm you have html2wiki installed on your computer, and if not, will install it." [[ -x /usr/bin/html2wiki ]] || sudo apt-get -y install libhtml-wikiconverter-moinmoin-perl # need to check for gedit [[ -x /usr/bin/gedit ]] || sudo apt-get -y install gedit # need to check for zenity [[ -x /usr/bin/zenity ]] || sudo apt-get -y install zenity # Variables DIR="${HOME}/Documents/ubforums2ubwiki" AWK=$(which awk) GREP=$(which egrep) SED=$(which sed) CONVERT='html2wiki --dialect MoinMoin' WGET=$(which wget) ZENITY=$(which zenity) NAME='' URL='' GEDIT=$(which gedit) CAT='/bin/cat' # What post to transcribe # Download the page to ~/$HOME/Documents/ubforums2ubwiki/file.html URL=$($ZENITY --entry --title="Tutorial to transcribe" --text="Paste the tutorial URL from your browser") return_value=$? if [ "$return_value" -ne "0" ]; then exit 1; fi # The was dialog to select what to convert, we can add it in later #echo "Enter filename." #read yourfile # What working name to give our pages NAME=$($ZENITY --entry --title="Title?" --text="Please enter your title") return_value=$? if [ "$return_value" -ne "0" ]; then exit 1; fi FILE="${DIR}/${NAME}.html" CLEAN="${DIR}/${NAME}.clean.html" WIKI="${DIR}/${NAME}.wiki" # Download $WGET "${URL}&postcount=1" -O "${FILE}" return_value=$? if [ "$return_value" -ne "0" ]; then echo -e '\e[0;31m' "Download Failed"; exit 1; fi # Clean up the raw html and then convert the clean html # GREP -v '(Code|Quote):' removes the "Code:" and "Quote:" divisions $AWK '/-- message --/,/\/ message --/' "${FILE}" | $GREP -v '(Code|Quote):' > "${CLEAN}" # Add wiki page header $CAT <<EOF>"${WIKI}" ## <<Include(Tag/ContentCleanup)>> ## <<Include(Tag/StyleCleanup)>> ## <<Include(Tag/NeedsExpansion)>> ||<tablestyle=\"float:right\; font-size:0.9em\; width:40%\; background:#F1F1ED\; margin: 0 0 1em 1em\;\" style=\"padding:0.5em\;\"><<TableOfContents>>|| EOF # Convert # The forums use [[BR]] for page breaks, the sed statement converts them to new lines # The second sed http[s]: ... formats wiki links $CONVERT "${CLEAN}" | $SED -e 's|\[\[BR\]\]|\n|g' | $SED -e 's/\(\[http[s]*:\S*\)\(.*\]\)\(.*\)/\[\1|\2\]\3 /g' >> "${WIKI}" #Cleanup # Review the document $GEDIT "${WIKI}" #This is an old line from a previous attempt at this script. # Not sure what the problem was , so left it #sed -r 's/[^[:space:]]*\.(jpg|jpeg|png|gif)/{{&}}/g' $yourfile.new > $yourfile
Save this as /usr/local/bin/ubforums2ubwiki.sh
or
~/bin/ubforums2ubwiki.sh
Make it executable
sudo chmod a+x /usr/local/bin/ubforums2ubwiki.sh
Run the tool
ubforums2ubwiki.sh
or create a desktop launcher. An image to be used as an icon can be found at https://launchpadlibrarian.net/101180651/logo64.png
Running the tool will cause an entry box to show - paste in the URL for the first post of the tutorial you wish to convert. Followed when prompted by name for the new wiki - do not use spaces in the name.
Once the tool has run - a gedit window will open with the text you can use for the wiki creation
You can either create a new page by directly entering it's name, if it does not exist you will be prompted to create the new page.
Alternatively you can use the Page Creation macro to do so.
Once you have the new page, paste in the text from your new foo.txt.new file, check for any further editing and when happy save changes. You can if you wish preview the page before saving.
Other Options
If you would like to just drop some links that you think are nice. You may do it at this page HERE and others will convert for you.