This repository has been archived by the owner on Oct 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.sh
141 lines (111 loc) · 2.61 KB
/
create.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
#!/bin/bash
createnotebook (){
##------ CHECK INPUT ------##
if [[ $# -eq 0 ]]
then
echo "Error: You must enter a filename for the new lab notebook"
return
fi
##------ CREATE FOLDER ------##
# Check if .git folder is present
if [[ $(find -d .git 2>&1 | grep -v 'No such file' | wc -l) -eq 0 ]]
then
echo -e "Error: There is no .git folder in the current working directory. \nPlease go to the folder where .git is to create new notebook in the same folder"
return
fi
# Create folder
mkdir .labnotebook
##------ USEFUL VARIABLES ------##
today=$(date +'%Y-%m-%d')
aut=$(git config --get user.name)
red='\033[0;31m'
green='\033[0;32m'
ncol='\033[0m'
##------ POPULATE FOLDER ------##
# Create config
echo -e "NOTEBOOK_NAME='$*'
LAB_AUTHOR=\"$aut\"
LAST_COMMIT=no
LAST_DAY=no
SHOW_ANALYSIS_FILES=yes
LAB_CSS=.labnotebook/labstyles.css
ANALYSIS_EXT=('.html')" > .labnotebook/config
# Create HEAD
echo "<\!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<title>$1 Lab notebook</title>
</head>" | awk '{print $0}' > .labnotebook/head.html
sed -i '' 's/\\//' .labnotebook/head.html
# Create BODY
echo "<body>
<header>
<h1 id='labtitle'>$1 lab notebook</h1>
<p id='creationdate'>Created on: $today</p>
<p id='labauthor'>Author: $aut</p>
</header>
<main>
</main>
</body>" > .labnotebook/body.html
# Create FOOTER
echo "</html>" > .labnotebook/footer.html
# Create CSS
echo -e "
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
padding: 1rem;
}
h1 {
color: red;
text-align: center;
font-size: 2.5em;
}
h2 {
text-align: center;
border: 1px solid red;
font-size: 1.875em;
}
h3 {
font-weight: bold;
margin: 1em 0em 0.2em 0em;
font-size: 1.2em;
}
details {
font-size: 1em;
cursor: pointer;
display: inline
}
details li {
cursor: text;
padding-left: 0.5em;
font-size: 1em;
margin-left: 3em;
}
p {
margin: 0.2em 0em;
font-size: 1em;
}
.analyses-el {
display: block;
}
.analyses-el li {
margin-left: 3em;
padding-left: 0.5em;
}
.commit-el {
padding: 1rem;
}
.sha-el {
margin-top: 1em;
}
" > .labnotebook/labstyles.css
##------ CONFIRMATION MESSAGE ------##
echo -e "\n$green .labnotebook folder succesfully created\n$red Mandatory: when updating the notebook, make sure you are in $(pwd)\n Never change .labnotebook folder name or content $ncol"
}