root/misc/diu_graph.sh

Revision 971, 1.5 kB (checked in by alpt, 2 years ago)

links updated

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/bash
2 #
3 #                       diu_graph.sh
4 #
5 # Del.icio.us graph generator
6 # http://freaknet.org/alpt/src/misc/diu_graph.sh
7 #
8 # --
9 #
10 # This script retrieves your Del.icio.us bookmarks and generates a graph of
11 # your tags.
12 #
13 # Two tags are considered connected if they belong to the same URL.
14 # Two URLs are connected if they share at least one tag.
15 #
16 # Note that if you have more than 200 tags, the graph maybe VERY BIG.
17 # Use http://zvtm.sourceforge.net/zgrviewer.html to view it.
18 #
19 # This script depends on Graphviz: http://www.graphviz.org/
20 #
21 # AlpT (@freaknet.org)
22 #
23
24 ###### CONFIGURE HERE ######
25 DIU_USER=""
26 DIU_PASSWD=""
27 ###### CONFIGURE HERE ######
28
29
30 if [ -z "$DIU_USER" ] || [ -z "$DIU_PASSWD" ]
31 then
32         echo Please configure your del.icio.us username and password.
33         echo Change their values in $0.
34         exit 1
35 fi
36
37 echo "Retrieving the bookmarks in myDelicious.xml"
38 curl --user "$DIU_USER":"$DIU_PASSWD" -o myDelicious.xml -O 'https://api.del.icio.us/v1/posts/all'
39
40 echo "Generating tags.dot"
41 cat myDelicious.xml  | awk '{ match($0, /tag="([^"]+)"/, arr); print arr[1];}' \
42 | grep -v "^$" | sort -u > tags
43
44 echo "graph G {" > tags.dot
45 echo "node [shape=plaintext, fontsize=24]
46 //edge [len=3]
47 //nodesep=3" >> tags.dot
48
49 cat tags | sed -e 's/ / -- /g'  -e 's/\./_/g' -e \
50 's/\(^\| \)\([0-9]\)/ _\2/g'  -e 's/:/_/g' -e \
51 's/\([A-Za-z0-9]\)-\([A-Za-z0-9]\)/\1_\2/g' >> tags.dot
52 echo "}" >> tags.dot
53
54 echo "Executing graphviz on tags.dot, the result will be saved on tags.svg"
55 echo "This process may take very LONG time"
56 fdp tags.dot -Tsvg > tags.svg
57
Note: See TracBrowser for help on using the browser.