Giter VIP home page Giter VIP logo

gitlog's Introduction

Git Log app

Gitlog is a svelte frontend only app I use to share my git commit calendars in github format. Gitlog requires a script running from cron updating the git project logs, and an nginx webserver to serve this app and to serve the gitlog files in json format

example: https://de-neef.net/gitlog

Installation

Prepare git-server

Install this script on your git-server. I use git-shell, so should be installed in git-shell-commands directory

#!/bin/sh
# gitlog's update_gitlog script, run from cron daily

set -x

BD=/srv/gitlogs
AFTER=${1:-"yesterday 0:00"}
BEFORE=${2:-"today 0:00"}
LOGALL=

umask 022
for i in *.git
do
  LOG=$(git --git-dir $i log --all --after="$AFTER" --before="$BEFORE" --pretty=format:%ad --date=short)
  if [ -n "$LOG" ]; then
    [ -z "$LOGALL" ] && LOGALL="$LOG" || LOGALL="$LOGALL\n$LOG"
    GD=${i%.git}
    FO=$BD/$GD
    mkdir -p "$FO"
    rm -f $FO/* # cleanup old files
    echo -e "$LOG" | sort | uniq -c >> "$FO/git.log"
    for readme in `git --git-dir $i ls-tree -r master --name-only | grep -Ei '^(install|readme)\.(txt|md)$'`
    do
      git --git-dir $i archive master $readme | tar -xO >> "$FO/$readme"
    done
  fi
done

if [ -n "$LOGALL" ]; then
  echo -e "$LOGALL" | sort | uniq -c >> $BD/git.log
fi

# cleanup old gitlogs
for i in $BD/*
do
  if [ -d $i ]; then
    [ ! -d $HOME/$i.git ] && rm -rf $i
  fi
done

exit 0

And add cron job:

3       0       *       *       *       update_gitlogs >> /tmp/gitlog.output 2>&1

Prepare nginx webserver for serving app and git logs

Add this config to your nginx webserver:

        location /gitlog {
                alias /var/www/localhost/gitlog/;
                try_files $uri $uri/ =404;
                location /gitlog/gitlogs {
                        # add_header Access-Control-Allow-Origin *;
                        alias /srv/gitlogs/;
                        autoindex on;
                        autoindex_format json;
                        autoindex_localtime on;
                }
        }

Prepare and install this app

Get the app: git clone <git endpoint>/gitlog.git

Install app:

cd gitlog
npm install

Build and cp app to remote host

npm run build
# copy to remote host, I use linux containers (lxd)
tar cvf - public | ssh $SSH_REMOTE "cat > build.tar"
ssh $SSH_REMOTE
lxc file push build.tar $LXC_REMOTE /root/build.tar
lxc exec $LXC_REMOTE sh
cd /var/www/localhost
tar xvf /root/build.tar 
mv public gitlog
chown -R root.www-data gitlog
chmod -R u+rwX,g+rX gitlog

or in 1 go:

read -p "cp to $LXC_REMOTE via $SSH_REMOTE, continue? " -r -n 1 -t 5; [[ $REPLY =~ ^[Yy]$ ]] && npm run build && tar cvf - public | ssh $SSH_REMOTE "lxc exec $LXC_REMOTE -- sh -c 'cat > /var/www/localhost/public.tar; cd /var/www/localhost; tar xvf public.tar; chown -R root.www-data public; chmod -R u+rwX,g+rX-w,o-rwx public; rm -rf gitlog; mv public gitlog; rm public.tar'"

That should be it.

gitlog's People

Contributors

jdeneef avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.