1 | commit ff64ffad0cec3b9263e00c87299d8e4cff2c1f25 |
2 | Author: acidvegas <acid.vegas@acid.vegas> |
3 | Date: Thu Apr 9 17:21:17 2020 -0400 |
4 | |
5 | Fixed bashism and cleaned up source |
6 | --- |
7 | README.md | 6 +--- |
8 | stagit | 111 ++++++++++++++++++-------------------------------------------- |
9 | 2 files changed, 32 insertions(+), 85 deletions(-) |
10 | |
11 | diff --git a/README.md b/README.md |
12 | index 997263d..f607129 100644 |
13 | --- a/README.md |
14 | +++ b/README.md |
15 | @@ -17,7 +17,6 @@ A live demo of this script can be seen [here](https://acid.vegas). |
16 | | MAX_COMMIT_MSG | 100 | maximum characters in a commit message to display *(0 = all)* | |
17 | | MAX_COMMIT_LINES | 999 | maximum number of lines to show in a commit *(0 = all)* | |
18 | | REPO_DIR | $HOME/git | directory containing repositories | |
19 | -| THEME | light | style used *(light or dark)* | |
20 | | TITLE | "Repositories" | title used on homepage | |
21 | | WWW_DIR | $HOME/www | directory to output to | |
22 | |
23 | @@ -28,13 +27,10 @@ The `CNAME` option is optional if you are planning on using a custom domain with |
24 | Lastly, stagit will ignore the `$REPO_DIR/mirrors` directory by default. To make stagit include this directory, remove `-path $REPO_DIR/mirrors -prune` from the `find` command in the source. |
25 | |
26 | ## Todo |
27 | -- mailto links in commits and more |
28 | -- Create an index per-user to view specific users repos & key information. |
29 | -- Pagination support for repos exceeding `MAX_COMMITS`. |
30 | - Add a footer to all pages with the last updated datetime and a link to this repository. |
31 | - Hook git pushes to rebuild the repositories index. |
32 | - Add support for displaying LICENSE/README files and convert markdown to HTML. |
33 | -- Add support to view file contents. |
34 | +- Add support to view file contents *(have to detect all non-binary files to exclude images, etc)*. |
35 | - Fix all possible bashisms identified in source by checkbashisms. |
36 | |
37 | ## Mirrors |
38 | diff --git a/stagit b/stagit |
39 | index d4b94d7..54b7c2c 100755 |
40 | --- a/stagit |
41 | +++ b/stagit |
42 | @@ -10,7 +10,6 @@ MAX_COMMITS=100 # maximum number of commits to show (0 = all) |
43 | MAX_COMMIT_MSG=100 # maximum characters in a commit message to display (0 = all) |
44 | MAX_COMMIT_LINES=999 # maximum number of lines to show in a commit (0 = all) |
45 | REPO_DIR=$HOME/git # directory containing repositories |
46 | -THEME='light' # default style used ('light' or 'dark') |
47 | TITLE='Repositories' # title used on homepage |
48 | WWW_DIR=$HOME/www # directory to output to |
49 | ####################################################################################### |
50 | @@ -19,86 +18,38 @@ generate_404() { |
51 | { |
52 | echo "<!doctype html>" |
53 | echo "<title>Error</title>" |
54 | - if [ $THEME = 'light' ]; then |
55 | - echo "<style>body{background-color:#fff;color:#000;font-family:monospace}</style>" |
56 | - else # We have to use internal CSS here because the style.css path will differ inside directories! |
57 | - echo "<style>body{background-color:#111;color:#fff;font-family:monospace}</style>" |
58 | - fi |
59 | + echo "<style>body{background-color:#111;color:#fff;font-family:monospace}</style>" |
60 | echo "<br><br><br><enter><h1>404</h1></center>" |
61 | } > $WWW_DIR/404.html |
62 | } |
63 | |
64 | -generate_yml() { |
65 | - { |
66 | - echo "pages:" |
67 | - echo " stage: deploy" |
68 | - echo " script:" |
69 | - echo " - mkdir .public" |
70 | - echo " - cp -r * .public" |
71 | - echo " - mv .public public" |
72 | - echo " artifacts:" |
73 | - echo " paths:" |
74 | - echo " - public" |
75 | - echo " only:" |
76 | - echo " - master" |
77 | - } > $WWW_DIR/.gitlab-ci.yml |
78 | -} |
79 | - |
80 | generate_css() { |
81 | - if [ $THEME = 'light' ]; then |
82 | - { |
83 | - echo "a{color:blue}" |
84 | - echo "body{background-color:#fff;color:#000;font-family:monospace;margin-top:0px}" |
85 | - echo "h1{margin:0px}" |
86 | - echo "h1 a{color:#000;text-decoration:none}" |
87 | - echo "h4{color:#777;margin:0px}" |
88 | - echo "h5{margin:0px;font-style:italic;font-weight:normal}" |
89 | - echo "hr{border:none;border-bottom:1px solid #777}" |
90 | - echo "pre{margin:0px}" |
91 | - echo ".bold{font-weight:bold}" |
92 | - echo ".branch{color:green;font-weight:bold}" |
93 | - echo ".commit{color:olive}" |
94 | - echo ".deletion{color:red}" |
95 | - echo ".hunk{color:teal}" |
96 | - echo ".insertion{color:green}" |
97 | - echo ".reference{color:teal;font-weight:bold}" |
98 | - echo ".remote{color:red;font-weight:bold}" |
99 | - echo ".item:hover{background-color:#eee}" |
100 | - echo ".item td{white-space:nowrap}" |
101 | - echo ".linenumber{text-align:right;-moz-user-select:-moz-none;-khtml-user-select: none;-webkit-user-select:none}" |
102 | - echo ".linenumber a{text-decoration:none}" |
103 | - echo "#main{border-collapse:collapse;table-layout:fixed}" |
104 | - echo "#main td,th{padding-left:5px;padding-right:5px}" |
105 | - echo "#navigation{color:#000;font-weight:900;text-align:left}" |
106 | - } > $WWW_DIR/style.css |
107 | - else |
108 | - { |
109 | - echo "a{color:#8dc}" |
110 | - echo "a:hover{color:#8cd}" |
111 | - echo "body{background-color:#111;color:#fff;font-family:monospace;margin-top:0px}" |
112 | - echo "h1{margin:0px}" |
113 | - echo "h1 a{color:#fff;text-decoration:none}" |
114 | - echo "h4{color:#777;margin:0px}" |
115 | - echo "h5{font-style:italic;font-weight:normal;margin:0px}" |
116 | - echo "hr{border:none;border-bottom:1px dashed #fff}" |
117 | - echo "pre{margin:0px}" |
118 | - echo ".bold{font-weight:bold}" |
119 | - echo ".branch{color:green;font-weight:bold}" |
120 | - echo ".commit{color:olive}" |
121 | - echo ".deletion{color:red}" |
122 | - echo ".hunk{color:teal}" |
123 | - echo ".insertion{color:green}" |
124 | - echo ".reference{color:teal;font-weight:bold}" |
125 | - echo ".remote{color:red;font-weight:bold}" |
126 | - echo ".item:hover{background-color:#1a1a1a}" |
127 | - echo ".item td{white-space:nowrap}" |
128 | - echo ".linenumber{text-align:right;-moz-user-select:-moz-none;-khtml-user-select: none;-webkit-user-select:none}" |
129 | - echo ".linenumber a{text-decoration:none}" |
130 | - echo "#main{border-collapse:collapse;table-layout:fixed}" |
131 | - echo "#main td,th{padding-left:5px;padding-right:5px}" |
132 | - echo "#navigation{color:#fff;font-weight:900;text-align:left}" |
133 | - } > $WWW_DIR/style.css |
134 | - fi |
135 | + { |
136 | + echo "a{color:#8dc}" |
137 | + echo "a:hover{color:#8cd}" |
138 | + echo "body{background-color:#111;color:#fff;font-family:monospace;margin-top:0px}" |
139 | + echo "h1{margin:0px}" |
140 | + echo "h1 a{color:#fff;text-decoration:none}" |
141 | + echo "h4{color:#777;margin:0px}" |
142 | + echo "h5{font-style:italic;font-weight:normal;margin:0px}" |
143 | + echo "hr{border:none;border-bottom:1px dashed #fff}" |
144 | + echo "pre{margin:0px}" |
145 | + echo ".bold{font-weight:bold}" |
146 | + echo ".branch{color:green;font-weight:bold}" |
147 | + echo ".commit{color:olive}" |
148 | + echo ".deletion{color:red}" |
149 | + echo ".hunk{color:teal}" |
150 | + echo ".insertion{color:green}" |
151 | + echo ".reference{color:teal;font-weight:bold}" |
152 | + echo ".remote{color:red;font-weight:bold}" |
153 | + echo ".item:hover{background-color:#1a1a1a}" |
154 | + echo ".item td{white-space:nowrap}" |
155 | + echo ".linenumber{text-align:right;-moz-user-select:-moz-none;-khtml-user-select: none;-webkit-user-select:none}" |
156 | + echo ".linenumber a{text-decoration:none}" |
157 | + echo "#main{border-collapse:collapse;table-layout:fixed}" |
158 | + echo "#main td,th{padding-left:5px;padding-right:5px}" |
159 | + echo "#navigation{color:#fff;font-weight:900;text-align:left}" |
160 | + } > $WWW_DIR/style.css |
161 | } |
162 | |
163 | generate_index() { |
164 | @@ -116,7 +67,8 @@ generate_index() { |
165 | generate_repository_index() { |
166 | local REPO_NAME=$1 |
167 | local REPO_URL=$2 |
168 | - local REPO_DESC=${@:3} # todo: fix possible bashism |
169 | + shift 2 |
170 | + local REPO_DESC="${@}" |
171 | mkdir -p $WWW_DIR/$REPO_NAME/commit |
172 | { |
173 | echo "<!doctype html>" |
174 | @@ -151,7 +103,7 @@ REPOS=$(find $REPO_DIR -type d -name mirrors -prune -o -type d -name .git -print |
175 | [ -z "$REPOS" ] && echo "'$REPO_DIR' contains no repositories" && exit 1 |
176 | mkdir -p $WWW_DIR && rm -rf $WWW_DIR/* |
177 | [ ! -z $CNAME ] && echo $CNAME > $WWW_DIR/CNAME |
178 | -generate_yml && generate_404 && generate_css && generate_index |
179 | +generate_404 && generate_css && generate_index |
180 | for d in $REPOS; do |
181 | REPO_NAME=$(basename -s .git `git --git-dir $d config --get remote.origin.url`) |
182 | if [ -f $d/description ]; then |
183 | @@ -216,6 +168,5 @@ for d in $REPOS; do |
184 | COUNT=`expr $COUNT + 1` |
185 | fi |
186 | done |
187 | - echo "</table></pre>" >> $WWW_DIR/$REPO_NAME/commit/$COMMIT_HASH.html |
188 | done |
189 | -done |
190 | +done |