Showing posts with label howto. Show all posts
Showing posts with label howto. Show all posts

Sunday, May 16, 2010

Gource and Dokuwiki

Like everyone, I am fond of the wonderful videos made with Gource. The goal of this tool is to make a representation of the changes made on a version control system like git or SVN. But my favorite wiki ( DokuWiki ) is a version control system tool... Have a look to the folder tree to find the directory "dokuwiki/data/meta" in which the files "*. changes" contain exactly the information sought. For example, the file "systemes_visualisation.changes" looks like:

1263135717 ::1 C informatique:systemes_visualisation Wolverine créée 1263135717:: 1 C computer: Wolverine created systemes_visualisation
1263135988 ::1 E informatique:systemes_visualisation Wolverine 1263135988:: 1 E it: Wolverine systemes_visualisation
1263136423 ::1 E informatique:systemes_visualisation Wolverine 1263136423:: E a computer: Wolverine systemes_visualisation

Explanation :

  1. the first column is a Unix Timestamp ,
  2. the second is the IP address (I'm working on localhost ;-))
  3. the third is the action performed (C created, E edited ,...)
  4. the fourth is straightforward,
  5. the fifth is the ID of the person who modified the page
  6. and the last column is the smallest text you can perform when you edit a page ...
Now just turn this tree into a log file readable by Gource . To do this, I developed a small python script named gourcedoku.py:

#!/bin/python

"""
This program parse logs of a dokuwiki
and tranform them for gource (a log viewer)
http://code.google.com/p/gource/

developped by WolverineX02
site : http://wolverinex02.blogspot.com

"""

import os.path
import getopt
import sys
import re



def listdirectory2(path):
"""list all the files like *.changes,
read them and output them in gource's log syntax
"""
for root, dirs, files in os.walk(path):
for i in files:
if (re.search('\.changes$', i)):
fichier = os.path.join(root, i)
myfile = open(fichier, 'r')
for line in myfile.readlines():
mots = line.split()
if len(mots)>=5:
resultat = mots[0] + "|"
resultat += mots[4] + "|"
resultat += translate(mots[2]) + "|"
resultat += fichier
print resultat
elif len(mots)==4:
resultat = mots[0] + "|Anonymous|"
resultat += translate(mots[2]) + "|"
resultat += fichier
print resultat
myfile.close()

def translate(mot):
"""translate the dokuwiki vocabulary to the gource one
C -> A
E -> M
other -> M
"""
if mot == "C":
return "A"
elif mot == "E":
return "M"
else:
return "M"

def main(argv):
"""principal function
"""
try:
opts, args = getopt.getopt(argv, "hd:", ["help", "dokuwiki="])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ("-h","--help"):
usage()
sys.exit()
elif opt in ("-d","--dokuwiki"):
print listdirectory2(arg)


def usage():
"""this function will display how to use this script
"""
print "This script will output change logs of a dokuwiki"
print "in a friendly way for gource"
print "how to use it :"
print "python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log"
print "and then :"
print "gource --log-format custom dokusort.log --stop-position 1.0 \ "
print "--stop-on-idle --file-idle-time 10000000"
print "---"
print "-h : help "
print "-d : meta directory of your dokuwiki"


if __name__ == "__main__":
main(sys.argv[1:])


To start it, nothing more simple, launch the script in yout dokuwiki directory :

python gourcedoku.py -d ~/Sites/MyDokuwiki/ | sort > dokusort.log
then view the result with Gource with the following command:
gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000

I will try to put this code on the site Gource site ;-) Feel free to ask me questions or to improve my script.

Sunday, December 13, 2009

How to import Mac OS X's icons in Visio

You certainly know the program Visio (Microsoft Office) that allows to make beautiful diagrams ... the only small snag, Visio's icons are particularly ugly... Therefore let me show you two techniques to import the beautiful Snow Leopard icons in your Visio.

Method: by hand

Select the application whose you want import the icon (with the famous Apple + C), then open the Preview application and choose "New from clipboard"
you will just have to save it as and choose the PNG format. You can now import your image into Visio.

Second method: using a script

The previous method let you to extract only an icon at a time, if you want to retrieve all the icons of Mac OS X, you can use the following python script:


/bin/python

import os
import re

text = "0000"
out = "~/Pictures/"

stdout_handle = os.popen ( "find / -name *. icns", "r")
while (text !=""):
stdout_handle.readline text = ()
regnamefile = re.compile ( '\/([^//]*)\. icns')
namefile = regnamefile.findall (text) [0]
Reglin = re.compile ( '(\/ .*\. icns)')
line = regline.findall (text) [0]
os.system ( "sips-s format png"+line+"-out"+out+namefile+".png")

Beware the indentation : it is the python ... ;-) The script first look for all icns file (the format of the icons of Mac OS X ;-) ;-)), then apply a transformation using the application sips available on Mac OS X. All files in PNG format will be created in your pictures folder ...

That ;-) I hope you will make beautiful patterns after that.

Sunday, June 08, 2008

Installing Wikicalc: the most beautiful OpenSource spreadsheets

As I indicated in my last post: WikiCalc is a collaborative spreadsheet operating on the principle of wiki. It is completely written in Perl. To install Wikicalc, nothing more simple, just start by installing the necessary tools for your good old Debian:
apt-get install apache2 libapache2-mod-perl2
Then download sources: wikicalc-1-0.tar.gz. Then can begin the installation process itself:
cd /var/www
tar xvzf wikicalc-1-0.tar.gz
ln -s wikicalc-1-0 wikicalc

Now you have to let the Wikicalc engine to be accessible from your Web server: compared to the configuration by default, you just need to add these few lines :



NameVirtualHost *

ServerAdmin webmaster@localhost

DocumentRoot /var/www/wikicalc/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews ExecCGI
AddHandler cgi-script .cgi .pl
AllowOverride None
Order allow,deny
allow from all





Load Perl module:
a2enmod perl
restart /etc/init.d/apache2

To finish the installation, go to http://wikicalc.monsite.com/wikicalccgi.pl and follow the instructions ....

Now you can play with this imressive spreedsheat