From b928dbe13a390f1cba736d40192a9c38e04e6d7d Mon Sep 17 00:00:00 2001 From: MediaWiki default Date: Wed, 15 Jun 2011 02:39:50 +0000 Subject: [PATCH] Create MediaWiki page 'Home' --- Categories.mediawiki | 2 ++ Home.mediawiki | 8 +++++++ category.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 Categories.mediawiki create mode 100644 Home.mediawiki create mode 100755 category.sh diff --git a/Categories.mediawiki b/Categories.mediawiki new file mode 100644 index 0000000..431f552 --- /dev/null +++ b/Categories.mediawiki @@ -0,0 +1,2 @@ + +The following categories contain pages or media. diff --git a/Home.mediawiki b/Home.mediawiki new file mode 100644 index 0000000..47cd2f0 --- /dev/null +++ b/Home.mediawiki @@ -0,0 +1,8 @@ +'''MediaWiki has been successfully installed.''' + +Consult the [http://meta.wikimedia.org/wiki/Help:Contents User's Guide] for information on using the wiki software. + +== Getting started == +* [http://www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings list] +* [http://www.mediawiki.org/wiki/Manual:FAQ MediaWiki FAQ] +* [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list] \ No newline at end of file diff --git a/category.sh b/category.sh new file mode 100755 index 0000000..9caeb5e --- /dev/null +++ b/category.sh @@ -0,0 +1,52 @@ +#!/bin/bash +cd "$(dirname "$0")" + +function prepareFile(){ + path="$1" + tmp_path="$(basename "$path").tmp" + ( + grep 'CODE AUTOMATICALLY GENERATED BY category.sh -->' "$path" &>/dev/null + if [ $? -eq 0 ] + then + sed -n '/CODE AUTOMATICALLY GENERATED BY category.sh -->/q;p' "$path" + else + cat "$path" && echo + fi + echo -e '' + ) > "$tmp_path" + echo "$tmp_path" +} + +function finishFile(){ + path="$1" + tmp_path="$(basename "$path").tmp" + mv "$tmp_path" "$path" +} + +files_lines_categories="$(grep '^\[\[Category [^]./\]*\]\]$' *)" +#echo "files_lines_categories: $files_lines_categories" + +echo '' > Categories.mediawiki +echo 'The following categories contain pages or media.' >> Categories.mediawiki + +echo "$files_lines_categories" | grep -o 'Category [^]]*' | sort | uniq | while read category +do + #echo "category: $category" + + category_file="$(echo "$category" | sed 's/ /-/g').mediawiki" + echo "category_file: $category_file" + + result="$(prepareFile "$category_file")" + echo "== '''Pages in category \"$(echo $category | sed 's/Category //')\"''' ==" >> "$result" + files="$(echo "$files_lines_categories" | grep ":\[\[${category}\]\]$" | sort)" + num_pages="$(echo "$files" | wc -l)" + + echo -e "* [[$category]] ($num_pages members)" >> Categories.mediawiki + + echo "The following $num_pages pages are in this category." >> "$result" + echo "$files" | while read file + do + echo "* [[$(echo $file | sed -e "s/\.mediawiki:\[\[${category}\]\]$//" -e 's/-/ /g')]]" + done >> "$result" + finishFile "$category_file" +done \ No newline at end of file