-
Notifications
You must be signed in to change notification settings - Fork 4
/
jithub.sh
executable file
·183 lines (136 loc) · 5.26 KB
/
jithub.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
#Pierre JACQUET
#28/10/2017
#Lol Mr Taveau RPZ
echo 'function getTree() {
var data = ' > ./js/menu.js #I'm a noob so i create the js directly - i don't know how to load json into javascript next
/usr/bin/tree COURS/* -f --noreport -D -P '*\.md|*\.pdf' --dirsfirst --prune -C -J >> ./js/menu.js #output JSON TREE \o/ YEAHHH
filename="./js/menu.js"
sed -i -e 's/\"name\"/href/g' js/menu.js #replace name by href to match bootstrap standards
lineNo=1
while read -r line #Read each line of menu.js
do
ligne="$line"
if [[ $ligne == *"href"* ]]; then
nameextract=`echo $ligne | sed 's/\",\"contents\":\[//'`
nameextract=`echo $nameextract | sed 's/\"},//'`
nameextractf=${nameextract##*/}
nameextractf=`echo $nameextractf | sed 's/\".*$//gm'`
echo $nameextractf
sed -i "${lineNo}s/$nameextractf\"/$nameextractf\",name:\"$nameextractf\"/" js/menu.js
fi
if [[ $ligne == *"directory"* ]]; then
sed -i "${lineNo}s/,href:\"[^\"]*\"/,href:\"#fh5co-work\"/" js/menu.js
fi
lineNo=$((lineNo+1))
done < "$filename"
sed -i -e 's/\"time\"/custom/g' js/menu.js #replace contents from standard json output to nodes to match bootstrap standards
sed -i -e 's/\"contents\"/nodes/g' js/menu.js #replace contents from standard json output to nodes to match bootstrap standards
sed -i -e 's/name/text/g' js/menu.js #replace name from standard json output to text in order to match bootstrap standards
sed -i -e 's/.md//g' js/menu.js #remove .md file extension
sed -i -e 's/COURS/http:\/\/bros-bioinfo.github.io\/COURS/g' js/menu.js #add-http://
#sed -i -e 's/bros-bioinfo.github.io/http:\/\/bros-bioinfo.github.io/g' menu.js #add-http://
#Formating date output from Oct 28 13:45 ----> 10281345
#OK SO I DON'T KNOW HOW TO USE DICTIONNARY IN BASH SCRIPT DON'T BLAME ME
sed -i -e 's/:\"Jan /:\"1/' js/menu.js
sed -i -e 's/:\"Feb /:\"2/' js/menu.js
sed -i -e 's/:\"Mar /:\"3/' js/menu.js
sed -i -e 's/:\"Apr /:\"4/' js/menu.js
sed -i -e 's/:\"May /:\"5/' js/menu.js
sed -i -e 's/:\"Jun /:\"6/' js/menu.js
sed -i -e 's/:\"Jul /:\"7/' js/menu.js
sed -i -e 's/:\"Aug /:\"8/' js/menu.js
sed -i -e 's/:\"Sep /:\"9/' js/menu.js
sed -i -e 's/:\"Oct /:\"10/' js/menu.js
sed -i -e 's/:\"Nov /:\"11/' js/menu.js
sed -i -e 's/:\"Dec /:\"12/' js/menu.js
sed -i -e 's/\([0-9]\) \([0-9]\)/\1\2/g' js/menu.js
sed -i -e 's/\([0-9]\):\([0-9]\)/\1\2/g' js/menu.js
echo ';
return data;
}
var $searchableTree=$("#tree").treeview({
data: getTree(),
enableLinks: true,
showBorder: false,
showIcon: true,
showCheckbox: false,
expandIcon: "fa fa-folder",
collapseIcon: "fa fa-folder-open",
emptyIcon: "fa fa-file-text-o",
tags: ["available"],
showTags: true,
// colors
color: "#428bca",
backColor: undefined,
borderColor: undefined,
onhoverColor: "#F5F5F5",
selectedColor: "#FFFFFF",
selectedBackColor: "#428bca",
searchResultColor: "#D9534F",
searchResultBackColor: undefined,
onNodeSelected: function(event, node) {
if (node.nodes == undefined) {
// sends node info to another element
} else if (node.state.expanded) {
// TODO collapse children
collapseNode(node.nodeId);
} else {
// TODO expand children
expandNode(node.nodeId);
}
// var children = node["nodes"];
// alert( node["nodes"][0].custom ) ;
}
});
// SEARCH
var search = function(e) {
var pattern = $("#input-search").val();
var options = {
ignoreCase: true,
exactMatch: false,
revealResults: true
};
var results = $searchableTree.treeview("search", [ pattern, options ]);
var output = "<p>" + results.length + " matches found</p>";
$.each(results, function (index, result) {
output += "<p>- " + result.text + "</p>";
});
$("#search-output").html(output);
}
$("#btn-search").on("click", search);
//$("#input-search").on("keyup", search);
$("#btn-clear-search").on("click", function (e) {
$searchableTree.treeview("clearSearch");
$("#input-search").val("");
$("#search-output").html("");
$("#tree").treeview("collapseAll", { silent: true }); // COLLAPSE ALL
});
//COLLAPSE
$("#tree").treeview("collapseAll", { silent: true }); // COLLAPSE ALL AT START
function collapseNode(nodeId) {
$("#tree").treeview("collapseNode", [nodeId]);
}
function expandNode(nodeId) {
$("#tree").treeview("expandNode", [nodeId]);
}
//});
$("#recent").load("last-modified-files.txt");
' >> js/menu.js
#NOW we will get list of last modified file and we filter the list to show only md
git log --pretty=format: --name-only --since="4 days ago" | sort | uniq > last-modified-filestemp.txt
cat last-modified-filestemp.txt > last-modified-files.txt
sed -i '/\.md/!d' last-modified-files.txt
sed -i '/\"/d' last-modified-files.txt
while read -r line #Read each line of last-modified-files.txt
do
ligne="$line"
modified=${ligne##*/}
echo $modified
sed -i "s|$ligne|<a href=\"https:\/\/bros-bioinfo\.github\.io\/$ligne\">$modified<\/a><br>|" last-modified-files.txt
done < last-modified-files.txt
sed -i "s/\.md//g" last-modified-files.txt #Remove the md extension
echo '<!DOCTYPE html> <html> <head></head> <body>'| cat - last-modified-files.txt > temp && mv temp last-modified-files.txt
echo '</body></html>' >> last-modified-files.txt
rm last-modified-filestemp.txt
git add --all; git commit -m $1; git push --all