1 | commit cb8344bae6df17d2a767996a795d421e7690af02 |
2 | Author: acidvegas <acid.vegas@acid.vegas> |
3 | Date: Sat May 2 01:10:32 2020 -0400 |
4 | |
5 | Fixed nullbyte errors and added footers |
6 | --- |
7 | README.md | 10 +++++----- |
8 | stagit | 25 +++++++++++++++++++------ |
9 | 2 files changed, 24 insertions(+), 11 deletions(-) |
10 | |
11 | diff --git a/README.md b/README.md |
12 | index f607129..9d5a98f 100644 |
13 | --- a/README.md |
14 | +++ b/README.md |
15 | @@ -27,11 +27,11 @@ The `CNAME` option is optional if you are planning on using a custom domain with |
16 | 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. |
17 | |
18 | ## Todo |
19 | -- Add a footer to all pages with the last updated datetime and a link to this repository. |
20 | -- Hook git pushes to rebuild the repositories index. |
21 | -- Add support for displaying LICENSE/README files and convert markdown to HTML. |
22 | -- Add support to view file contents *(have to detect all non-binary files to exclude images, etc)*. |
23 | -- Fix all possible bashisms identified in source by checkbashisms. |
24 | +- Support for using hosting on Gitlab. |
25 | +- Git push hook. |
26 | +- Support for displaying LICENSE/README files and convert markdown to HTML. *(`find . -type f -not -path '*/\.git/*' -exec grep -I -q . {} \; -print`)* |
27 | +- Support to view files and content. |
28 | +- Fix bashisms identified by checkbashisms. |
29 | |
30 | ## Mirrors |
31 | - [acid.vegas](https://acid.vegas/stagit) *(main)* |
32 | diff --git a/stagit b/stagit |
33 | index 54b7c2c..f882935 100755 |
34 | --- a/stagit |
35 | +++ b/stagit |
36 | @@ -46,6 +46,8 @@ generate_css() { |
37 | echo ".item td{white-space:nowrap}" |
38 | echo ".linenumber{text-align:right;-moz-user-select:-moz-none;-khtml-user-select: none;-webkit-user-select:none}" |
39 | echo ".linenumber a{text-decoration:none}" |
40 | + echo "#footer{border-top:1px dashed #fff;color:#444;font-size:smaller;margin-top:10px;padding-top:5px;width:100%}" |
41 | + echo "#footer a{color:#aaa;text-decoration:none}" |
42 | echo "#main{border-collapse:collapse;table-layout:fixed}" |
43 | echo "#main td,th{padding-left:5px;padding-right:5px}" |
44 | echo "#navigation{color:#fff;font-weight:900;text-align:left}" |
45 | @@ -98,6 +100,11 @@ generate_commit_index() { |
46 | } > $WWW_DIR/$REPO_NAME/commit/$COMMIT_HASH.html |
47 | } |
48 | |
49 | +generate_footer() { |
50 | + local DATE=$(date +"%m/%d/%y") |
51 | + echo "<div id=\"footer\">site generated by <a href=\"https://github.com/acidvegas/stagit\" target=\"_blank\">stagit</a> on <a href=\"#\">$DATE</a></div>" >> $1 |
52 | +} |
53 | + |
54 | [ ! -d $REPO_DIR ] && echo "'$REPO_DIR' directory does not exist" && exit 1 |
55 | REPOS=$(find $REPO_DIR -type d -name mirrors -prune -o -type d -name .git -print | sort -t '/' -k 7) |
56 | [ -z "$REPOS" ] && echo "'$REPO_DIR' contains no repositories" && exit 1 |
57 | @@ -116,7 +123,7 @@ for d in $REPOS; do |
58 | echo "missing description file for $REPO_NAME ($d/description)" |
59 | REPO_DESC="no description available" |
60 | fi |
61 | - REPO_OWNER=$(git --git-dir $d log --reverse --pretty=format:'%an' | head -n 1) # todo: find a better way to do this & handle organization name parsing |
62 | + REPO_OWNER=$(git --git-dir $d log --reverse --pretty=format:'%an' | head -n 1) |
63 | REPO_LAST_COMMIT=$(git --git-dir $d log -1 --pretty=format:'%cs') |
64 | echo "<tr class=\"item\"><td><a href=\"$REPO_NAME\" title=\"$REPO_NAME\">$REPO_NAME</a></td><td>$REPO_DESC</td><td>$REPO_OWNER</td><td>$REPO_LAST_COMMIT</td></tr>" >> $WWW_DIR/index.html |
65 | if [ $CLONE_URL = 'remote' ]; then |
66 | @@ -155,7 +162,7 @@ for d in $REPOS; do |
67 | COMMIT_DELETIONS=$(echo $COMMIT_SUMMARY | cut -d'|' -f3) |
68 | echo "<tr class=\"item\"><td>$COMMIT_SIGNED</td><td><a href=\"commit/$COMMIT_HASH.html\" title=\"View this commit\">$COMMIT_HASH</a></td><td>$COMMIT_MESSAGE</td><td>$COMMIT_AUTHOR</td><td>$COMMIT_DATE</td><td align=\"right\">$COMMIT_FILES</td><td align=\"right\">$COMMIT_INSERTIONS</td><td align=\"right\">$COMMIT_DELETIONS</td></tr>" >> $WWW_DIR/$REPO_NAME/index.html |
69 | generate_commit_index $REPO_NAME $COMMIT_HASH |
70 | if [ $MAX_COMMIT_LINES -ne 0 -a $(echo "$COMMIT_DIFF" | wc -l) -gt $MAX_COMMIT_LINES ]; then |
71 | COMMIT_DIFF=$(echo "$COMMIT_DIFF" | head -n $MAX_COMMIT_LINES) |
72 | fi |
73 | @@ -163,10 +170,16 @@ for d in $REPOS; do |
74 | COMMIT_DIFF=$(echo "$COMMIT_DIFF" | sed 's/\[31m/<span class="deletion">/g; s/\[1\;31m/<span class="remote">/g; s/\[32m/<span class="insertion">/g; s/\[1\;32m/<span class="branch">/g; s/\[33m/<span class="commit">/g; s/\[36m/<span class="hunk">/g; s/\[1\;36m/<span class="reference">/g; s/\[1m/<span class="bold">/g; s/\[m/<\/span>/g') |
75 | COUNT=1 |
76 | echo "$COMMIT_DIFF" | while IFS= read -r line; do |
77 | - echo "<tr class=\"item\"><td class=\"linenumber\"><a href=\"#l$COUNT\" name=\"l$COUNT\">$COUNT</a></td><td><pre>$line</pre></td></tr>" >> $WWW_DIR/$REPO_NAME/commit/$COMMIT_HASH.html |
78 | - COUNT=`expr $COUNT + 1` |
79 | - fi |
80 | + echo "<tr class=\"item\"><td class=\"linenumber\"><a href=\"#l$COUNT\" name=\"l$COUNT\">$COUNT</a></td><td><pre>$line</pre></td></tr>" >> $WWW_DIR/$REPO_NAME/commit/$COMMIT_HASH.html |
81 | + COUNT=`expr $COUNT + 1` |
82 | + #fi |
83 | done |
84 | + echo "</table>" >> $WWW_DIR/$REPO_NAME/commit/$COMMIT_HASH.html |
85 | + generate_footer $WWW_DIR/$REPO_NAME/commit/$COMMIT_HASH.html |
86 | done |
87 | + echo "</table>" >> $WWW_DIR/$REPO_NAME/index.html |
88 | + generate_footer $WWW_DIR/$REPO_NAME/index.html |
89 | done |
90 | +echo "</table>" >> $WWW_DIR/index.html |
91 | +generate_footer $WWW_DIR/index.html |