Help:CSS cleanup

Jump to: navigation, search

This page describes how to replace hardcoded "style=..." with proper CSS classes.

You can find more details in the mailing list archive.

Workflow

  1. download all Template:* pages with the script below this section
  2. find templates using style= with grep -i style= templates/*
  3. take the styling from "style=...", find a proper CSS classname and write it to $page as a CSS class
    1. if the template is used as page template, store the exact style="..." code and the new classname on $otherpage - that makes it easier to cleanup those pages with search&replace later
  4. contact a wiki admin to move the CSS classes to MediaWiki:Common.css
  5. remove style= from all templates where you added class= before

Templates used as page templates

Templates used as page templates are listed in

Script to download all template pages

This script downloads all Template:* pages from en.opensuse.org. Please use it only if you want to work on CSS cleanup to avoid useless server load.

#!/bin/bash                                                                                                                                              
 
# where to store the templates
output_dir="./templates"
 
 
### you shouldn't need to change anything below this line ###
 
test -d "$output_dir" || mkdir -p "$output_dir" || { echo "can't mkdir $output_dir"; exit 1; }
cd "$output_dir" || { echo "can't cd to $output_dir"; exit 1; }
 
set -o pipefail
 
# get template list
wget -q 'http://en.opensuse.org/index.php?title=Special:Templates&limit=500&offset=0' -O - | \
    sed -n '/<!-- Begin Content Area -->/,/<!-- End Content Area -->/ s/^<li><a href="\/\([^"]*\)".*/\1/p' | \
    grep -v '/doc$' > template-list.txt || { echo "error downloading the tempate list"; exit 1; }
 
echo "List of templates (excluding */doc) stored in template-list.txt."
 
# download templates
while read template ; do
    echo -n "downloading $template...   "
    outfile=$(echo "$template" | sed 's§/§+§g')
    test "$template" = "$outfile" || echo -n "(saved as $outfile)   "
    wget -q "http://en.opensuse.org/index.php?title=$template&action=raw" -O "$outfile" && echo OK || { failures="$failures $template" ; echo failed; }
    sleep 1 # don't overload the wiki
done < template-list.txt
 
echo
echo "Templates saved in $output_dir"
test -n "$failures" && echo "Download failures: $failures"