Showing posts with label wiki. Show all posts
Showing posts with label wiki. Show all posts

Wednesday, May 19, 2010

Dokuwiki, Gource : color now

In response to various requests, I just added the color to the Dokuwiki representation with Gource. You can now download the new version .

#!/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 glob
import os.path
import getopt
import sys
import re

WHITE = "11FFAA"
GREEN = "00F000"
vector = (1,10,100)
start_page_name = "start"

def RGBToHTMLColor(rgb_tuple):
""" convert an (R, G, B) tuple to #RRGGBB """
hexcolor = '#%02x%02x%02x' % rgb_tuple
# that's it! '%02x' means zero-padded, 2-digit hex values
return hexcolor

def HTMLColorToRGB(colorstring):
""" convert #RRGGBB to an (R, G, B) tuple """
colorstring = colorstring.strip()
if colorstring[0] == '#': colorstring = colorstring[1:]
if len(colorstring) != 6:
raise ValueError, "input #%s is not in #RRGGBB format" % colorstring
r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
r, g, b = [int(n, 16) for n in (r, g, b)]
return (r, g, b)

def colormodify(colorstring):
rgb_tuple = HTMLColorToRGB(colorstring)
r, g, b = (rgb_tuple[0]+vector[0]) % 255,(rgb_tuple[1]+vector[1]) % 255,(rgb_tuple[2]+vector[2]) % 255
return RGBToHTMLColor((r, g, b))

def listdirectory(path,color):
l = glob.glob(path+"/*")
for i in l:
if os.path.isdir(i):
listdirectory(i,colormodify(color))
else:
readfile(i,color)

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)
readfile(fichier,GREEN)

def readfile(fichier,color):
"""read the file and output for each line of this
file a log line for Gource
"""

myfile = open(fichier, 'r')
for line in myfile.readlines():
mots = line.split('\t')
if len(mots)>=6:
resultat = mots[0] + "|"
if mots[4] == '':
mots[4] = 'Anonymous'
resultat += mots[4] + "|"
resultat += translate(mots[2]) + "|"
resultat += mots[3].replace(':', '/')
if mots[3].rfind(start_page_name) == len(mots[3])-len(start_page_name):
resultat += "|" + color
else:
resultat += "|" + colormodify(color)
print resultat
myfile.close()


def translate(mot):
"""translate the dokuwiki vocabulary to the gource one
C (also cc and sc from discussion plugin) ->A
E (also ec from discussion plugin) -> M
D (also dc and hc from discssion plugin) -> D
other -> M
"""
if mot.upper == "C" or mot == 'cc' or mot == 'sc':
return "A"
elif mot.upper == "E" or mot == 'ec':
return "M"
elif mot.upper == "D" or mot == 'dc' or mot == 'hc':
return "D"
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 listdirectory(arg,WHITE)


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:])


Sunday, May 16, 2010

Gource and Dokuwiki : the video

The video :






obtain with the followinf command line :

gource --log-format custom dokusort.log --stop-position 1.0 --stop-on-idle --file-idle-time 10000000 --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec mpeg4 gource.mp4


It takes a little time but the result is wonderful

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, 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

Saturday, January 27, 2007

A personal wiki for Math

A few weeks ago, I presented Tiddlywiki: a marvellous Javascript biggrin which enables you to have a wiki on your computer without apache… I also explained you that it is very difficult to make maths in HTML and on the occasion, I had spoken about jsMath, which enables you to do it biggrin… Why not to combine both, to obtain the dream tool to make maths, to take some notes… I will explain you how to make:

1. install Tiddlywiki: it is as easy as pie but you should install it in a dedicated directory…
2. download jsMath , decompress it in the same directory as Tiddlywiki
3. Then open your new personal wiki, “options>>” then “ImportTiddlers”
4. enter the URL of the plugin allowing to make the connection between Tiddlywiki and jsMath
http://bob.mcelrath.org/tiddlyjsmath-2.0.3.html#%5B%5BPlugin%3A%20Scientific%20Notation%5D%5D
5. click fetch and select the good plugin:
Plugin: jsMath /*** |Name|Plugin: jsMath| |Created by|BobMcElrath systemConfig systemTiddlers
6. reload the page (by pressing F5 for example)
7. Normally that should work.

Personally I had a small problem, it did not find def.js… I have thus to create in the file jsMath, this list of directory: fonts/cm-fonts/alpha/ and I copied there the file def.js which could be found in the directory uncompressed. Now it works perfectly. I hope to allow the development of mathematics biggrin

Saturday, October 07, 2006

An easy, personal wiki

I have always wanted to install a wiki on my laptop to write all the tips I find... But to install a wiki, most of the time you need Apache or MySql or PHP running on your personal laptop... It is OK if you want to run a wiki for a community but if you search something more personal, you probably don't want to use all that stuff... This morning, I find the solution: Tiddlywiki . To install it, just go on the web site of Tiddlywiki, go in the download section... And save a page!!! Yes Tiddlywiki consists on only one single HTML file with all you need inside: CSS and Javascript... Now you can write your first "Tiddler" an equivalent of a post in yout brand new wiki.