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

Wednesday, May 19, 2010

Gource et Dokuwiki : en couleur

ça y est suite aux différentes demandes, je viens d'ajouter la coloration de la représentation Gource. Vous pouvez donc télécharger la nouvelle 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:])

Tuesday, June 03, 2008

Wikicalc : le premier tableur collaboratif OpenSource

Comme je l'ai indiqué dans mon dernier poste : WikiCalc est un tableur collaboratif fonctionnant sur le principe du wiki. Il est complètement écrit en perl. Pour l'installer, rien de plus simple, il suffit de commencer par installer les outils nécessaires sur sa bonne vieille Debian :
apt-get install apache2 libapache2-mod-perl2
Puis de télécharger les sources : wikicalc-1-0.tar.gz. Ensuite peut commencer l'installation proprement dite :
cd /var/www
tar xvzf wikicalc-1-0.tar.gz
ln -s wikicalc-1-0 wikicalc

Reste encore à rendre Wikicalc accessible depuis votre serveur Web : par rapport à la configurationi par défaut, il suffit d'y ajouter :



NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/wikicalc/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/wikicalc/>
Options Indexes FollowSymLinks MultiViews ExecCGI
AddHandler cgi-script .cgi .pl
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>



On charge le module perl :
a2enmod perl
/etc/init.d/apache2 restart

Pour finir l'installation, rendez-vous sur http://wikicalc.monsite.com/wikicalccgi.pl et suivez les instructions....

Maintenant à vous de jouer

Connaissez-vous Dan Bricklin ???

Cet homme s'appelle Dan Bricklin, il a écrit le programme Visicalc. Comment ça vous ne connaissez pas Visicalc ??? Eh bien, c'est l'ancêtre d'Excel ou de Calc (OpenOffice)... Mais contrairement à Bill, Dan a préféré ne pas copyrighter son oeuvre... Merci Dan ;-)

Pourquoi vous parler de Dan Bricklin ? Simplement parce qu'il est en train de développer un super outil, toujours dans la même optique : un tableur collaboratif nommé Wikicalc. Je l'utilise pour les notes de nos élèves et y reporter les notes avec mes collègues... Adieu les tableaux Excels qu'on ne peut ouvrir qu'en lecture seule parce que votre collègue l'a modifié le matin mais a oublié de le fermer... En plus cet outil a le bon goût d'être Open Source et de reposer sur Perl (un langage que j'adore donc je le souligne ;-) J'espère que beaucoup d'autres personnes vont participer au développement de cet outil, qui je l'espère va concurrencer et peut être remplacer Google Docs... Révons d'un monde totalement Open Source ;-) Amusez-vous bien avec ce nouvel outil promis je l'espère à un grand avenir