Jump to content

User:Revansx/Gource/How to make a wiki evolution video using Gource

From mediawiki.org

What does this software do?

[edit]
This page captures my notes on how to extract edit history data from a mediawiki database and visualize it using the gource software
graphical visualization of all pages in a wiki based on edit history, colored by category and grouped by category and pagename

Wiki Server Steps

[edit]

Tailor the mysql command for your wiki database

[edit]
1. Find and replace the word "FOO" in the sql query below with the name of your wiki's database..
      (
          SELECT
              CAST(UNIX_TIMESTAMP(rev_timestamp) AS INT) as revtimestamp,
              actor_name as username,
              IF(rev_parent_id>0, 'M', 'A') as revtype,
              CONCAT('FOO/',cl_to,'/',page_title) as pagetitle,
              CASE page_namespace WHEN   0 THEN '266DD3' 
                                  WHEN   2 THEN 'FB5607' 
                                  WHEN   4 THEN 'FFBE0B' 
                                  WHEN   6 THEN 'FF006E' 
                                  WHEN   8 THEN '2EA513' 
                                  WHEN  10 THEN '8338EC' 
                                  WHEN  12 THEN 'FF00FF' 
                                  WHEN  14 THEN 'E71D36' 
                                  WHEN 102 THEN '00FFFF' 
                                  WHEN 106 THEN '00FF00' 
                                  WHEN 1 OR 3 OR 5 OR 7 OR 9 OR 11 OR 13 OR 15 OR 103 OR 107 THEN 'FFFF00' 
                                  ELSE 'FFFFFF' END as color
          FROM
               ( SELECT rev_id,
                        rev_timestamp,
                        rev_parent_id,
                        rev_page,
                        revactor_actor,
                        page_id,
                        page_namespace,
                        page_title,
                        actor.actor_id,
                        actor_name,
                        cl_from,
                        COALESCE(cl_to,'TBD')  AS cl_to
                 FROM `wiki_FOO`.revision
                 LEFT JOIN `wiki_FOO`.page ON page.page_id=rev_page
                 LEFT JOIN `wiki_FOO`.revision_actor_temp ON revision_actor_temp.revactor_timestamp=rev_timestamp
                 LEFT JOIN `wiki_FOO`.actor ON actor.actor_id=revactor_actor
                 LEFT JOIN `wiki_FOO`.categorylinks ON categorylinks.cl_from=rev_page
                 ORDER BY rev_timestamp ASC
               )a
          ORDER BY rev_timestamp ASC
      );

2. Open a command shell and enter the mysql command line interface with:

mysql

3. Then copy and past the tailored sql command above into the mysql CLI

RESULT: You should get a complete table of revision data ready for gource to consume

Work through any errors in the mysql until you get a nice output table

Colors
Main 0 266DD3
User 2 FB5607
Project 4 FFBE0B
File 6 FF006E
MediaWiki 8 2EA513
Template 10 8338EC
Help 12 FF00FF
Category 14 E71D36
Form 106 00FF00
Property 102 00FFFF
Talk 1, 3, 5, 7, 9, 11, 13, 15, 103, and 107 FFFF00
Everything Else else FFFFFF

Upload a mini text file to your wiki

[edit]
  1. create a text file named "GourceDataFromWiki.csv.txt" with content "123"
    • the contents don't matter. It will be over-written later with the gource log file
  2. Upload "GourceDataFromWiki.csv.txt" to your wiki

Make a shell script to automate the query of the edit history to file and other post-sql editing steps

[edit]

1. Create a shell script called "GetGourceDataFromWiki.sh" on your server

  • vi GetGourceDataFromWiki.sh

2. Copy the shell script below into GetGourceDataFromWiki.sh

  • note that the entire sql statement above is enclosed in `..` and so the "`" has to be escaped as "\\\`" in the shell script
#!/bin/sh

zResult=`mysql -e "
( SELECT
      CAST(UNIX_TIMESTAMP(rev_timestamp) AS INT) as revtimestamp,
      actor_name as username,
      IF(rev_parent_id>0, 'M', 'A') as revtype,
      CONCAT('FOO/',cl_to,'/',page_title) as pagetitle,
      CASE page_namespace WHEN   0 THEN '266DD3' 
                          WHEN   2 THEN 'FB5607' 
                          WHEN   4 THEN 'FFBE0B' 
                          WHEN   6 THEN 'FF006E' 
                          WHEN   8 THEN '2EA513' 
                          WHEN  10 THEN '8338EC' 
                          WHEN  12 THEN 'FF00FF' 
                          WHEN  14 THEN 'E71D36' 
                          WHEN 102 THEN '00FFFF' 
                          WHEN 106 THEN '00FF00' 
                          WHEN 1 OR 3 OR 5 OR 7 OR 9 OR 11 OR 13 OR 15 OR 103 OR 107 THEN 'FFFF00' 
                          ELSE 'FFFFFF' END as color
      FROM
          ( SELECT rev_id,
                rev_timestamp,
                rev_parent_id,
                rev_page,
                revactor_actor,
                page_id,
                page_namespace,
                page_title,
                actor.actor_id,
                actor_name,
                cl_from,
                COALESCE(cl_to,'TBD')  AS cl_to
            FROM \\\`wiki_FOO\\\`.revision
            LEFT JOIN \\\`wiki_FOO\\\`.page ON page.page_id=rev_page
            LEFT JOIN \\\`wiki_FOO\\\`.revision_actor_temp ON revision_actor_temp.revactor_timestamp=rev_timestamp
            LEFT JOIN \\\`wiki_FOO\\\`.actor ON actor.actor_id=revactor_actor
            LEFT JOIN \\\`wiki_FOO\\\`.categorylinks ON categorylinks.cl_from=rev_page
            ORDER BY rev_timestamp ASC
          )a
      ORDER BY rev_timestamp ASC
); "`

# Pipe the result of the sql query to a tab-separated ".dat" file
echo "$zResult" > GourceDataFromWiki.dat

# Convert the native sql "tab" delimited file to a "|" delimited CSV file
sed 's/\t/|/g' GourceDataFromWiki.dat > GourceDataFromWiki.csv

# Remove the headers in line 1 from the file 
echo -e "$(sed '1d' GourceDataFromWiki.csv)\n" > GourceDataFromWiki.csv

# Copy the gource-ready file to the place on your wiki server where the text file from step 1 is stored
cp GourceDataFromWiki.csv /opt/data-meza/uploads/FOO/7/7d/GourceDataFromWiki.csv.txt

From a Windows system with a good graphics card

[edit]

Download the gource custom log file to windows

[edit]

https://<YourWikiServer>/FOO/img_auth.php/7/7d/GourceDataFromWiki.csv.txt

Download and install gource

[edit]

https://gource.io/

Run gource on the log file

[edit]

Open a cmd and run:

"c:\Program Files\Gource\gource.exe" "c:\Users\user1\Desktop\stuff\gource\ptc\GourceDataFromWiki.csv.txt" --file-idle-time 0 --bloom-intensity 0.4 --max-file-lag 0.1 --seconds-per-day 0.5 --auto-skip-seconds 2 --date-format "%Y/%m/%d" --hide dirnames,filenames --font-size 36 --logo "c:\Users\user1\Desktop\stuff\gource\nasa-200x167.png" --title "Some Title"

Ref: https://github.com/acaudwell/Gource/wiki/Controls

Pipe gource into ffmpeg specifying bitrate to get smaller file

[edit]

Open a cmd and run:

"c:\Program Files\Gource\gource.exe" "c:\Users\user1\Desktop\stuff\gource\ptc\GourceDataFromWiki.csv.txt" --file-idle-time 0 --bloom-intensity 0.4 --max-file-lag 0.1 --seconds-per-day 0.5 --auto-skip-seconds 2 --date-format "%Y/%m/%d" --hide dirnames,filenames --font-size 36 -2560x1440 --logo "c:\Users\user1\Desktop\stuff\gource\logo.png" --title "Title" -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -b:v 5M -bufsize 2M "c:\Users\user1\Desktop\GourceWikiEvolution.mp4"
c:\Program Files\Gource\gource.exe" 
   "c:\Users\user1\Desktop\stuff\gource\ptc\GourceDataFromWiki.csv.txt" 
   --file-idle-time 0 
   --bloom-intensity 0.4 
   --max-file-lag 0.1 
   --seconds-per-day 0.5 
   --auto-skip-seconds 2 
   --date-format "%Y/%m/%d" 
   --hide dirnames,filenames 
   --font-size 36 -2560x1440 
   --logo "c:\Users\user1\Desktop\stuff\gource\logo.png" 
   --title "Title" -o - 
| ffmpeg 
   -y 
   -r 60 
   -f image2pipe 
   -vcodec ppm -i 
   -vcodec libx264 
   -b:v 5M 
   -bufsize 2M "c:\Users\user1\Desktop\GourceWikiEvolution.mp4"

Upload to YouTube

[edit]

In the usual way