summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2013-08-13 23:16:03 +0200
committerBertrand Jacquin <beber@meleeweb.net>2013-08-13 23:16:03 +0200
commit182641f11ef9d3f6d4e8c227ec68fab3dad2128b (patch)
treeb1045ee76efca3f52869ebc5d96f391374f5d175
Initial import
-rw-r--r--.gitignore9
-rw-r--r--.htaccess53
-rw-r--r--README18
-rw-r--r--cgitrc58
l---------filters/about-filter1
-rwxr-xr-xfilters/highlight81
l---------filters/source-filter1
-rw-r--r--filters/templates/rst2html.tmpl4
-rw-r--r--logo.pngbin0 -> 19506 bytes
l---------repos.txt1
10 files changed, 226 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b4bb394
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
1# Cache directory
2cache
3
4# Shipped from www-apps/cgit
5cgit.cgi
6cgit.css
7
8# Shipped from dev-vcs/git
9git-http-backend.cgi
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..b44ada4
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,53 @@
1# Force no Indexes in all cases
2# Force ExecCGI
3# FollowSymlinks for RewriteEngine
4Options -Indexes ExecCGI FollowSymlinks
5
6AddHandler cgi-script .cgi
7# No index.html or other things
8DirectoryIndex cgit.cgi
9
10# Config is locally hosted, not depending on root filesystem
11SetEnv CGIT_CONFIG ./cgitrc
12
13# git-html-backend config
14# GIT_HTTP_EXPORT_ALL is not defined, gitolite create git-daemon-export-ok
15SetEnv GIT_PROJECT_ROOT /srv/gitolite/repositories
16
17RewriteEngine On
18
19# Disable HTTPS
20RewriteCond %{ENV:HTTPS} On
21RewriteRule ^(.*) http://%{SERVER_NAME}/$1 [R=301,L]
22
23# Stop here if cgit is handling the request
24RewriteCond %{REQUEST_URI} ^/cgit\.cgi
25RewriteRule (.*) - [L]
26
27# Stop here if git-http-backend is handling the request
28RewriteCond %{REQUEST_URI} ^/git-http-backend\.cgi
29RewriteRule (.*) - [L]
30
31# Disable git-http-backend write access
32RewriteCond %{REQUEST_URI} ^(.*)\.git/git-receive-pack
33RewriteRule (.*) - [F,L]
34
35# Access to git files at the same URL than cgit, filter them
36RewriteCond %{REQUEST_URI} ^(.*)\.git/HEAD$ [OR]
37RewriteCond %{REQUEST_URI} ^(.*)\.git/info/refs$ [OR]
38RewriteCond %{REQUEST_URI} ^(.*)\.git/objects/info/[^/]+ [OR]
39RewriteCond %{REQUEST_URI} ^(.*)\.git/objects/[0-9a-f]{2}/[0-9a-f]{38}$ [OR]
40RewriteCond %{REQUEST_URI} ^(.*)\.git/pack/pack-[0-9a-f]{40}\.(pack|idx)$ [OR]
41RewriteCond %{REQUEST_URI} ^(.*)\.git/git-upload-pack$
42RewriteRule (.*) /git-http-backend.cgi/$1 [L,QSA]
43
44# Refuse to serve to users the config file
45RewriteCond %{REQUEST_URI} ^/cgitrc$
46RewriteRule (.*) - [F,L]
47
48# Serve local file
49RewriteCond %{REQUEST_FILENAME} -f
50RewriteRule .* - [L]
51
52# Access cgit from /
53RewriteRule ^([^/]+)(/?(.*)) /cgit.cgi/$1$2 [L,QSA,NS]
diff --git a/README b/README
new file mode 100644
index 0000000..f0ac8a7
--- /dev/null
+++ b/README
@@ -0,0 +1,18 @@
1** What is needed ?
2
3www-apps/cgit
4app-text/highlight # For general formatting/highlighting
5dev-python/markdown # For .md/about formatting
6dev-python/docutils # For .rst/about formatting
7
8** How to make this work ?
9
10# cgit core
11ln -s /usr/share/webapps/cgit/*/hostroot/cgi-bin/cgit.cgi cgit.cgi
12ln -s /usr/share/webapps/cgit/*/htdocs/cgit.css cgit.css
13
14# git http-backend
15ln -s /usr/libexec/git-core/git-http-backend git-http-backend
16
17# Beautify
18chmod +x filters/highlight
diff --git a/cgitrc b/cgitrc
new file mode 100644
index 0000000..5be175d
--- /dev/null
+++ b/cgitrc
@@ -0,0 +1,58 @@
1root-title=Enlightened git repositories
2
3# From http://enlightenment.org/p/index/d/logo.png
4logo=/logo.png
5# from http://enlightenment.org/favicon.png
6favicon=/favicon.ico
7css=/cgit.css
8
9robots=all
10
11clone-prefix=git://git.enlightenment.org http://git.enlightenment.org git+ssh://git@git.enlightenment.org
12
13virtual-root=/
14
15enable-index-links=0
16enable-index-owner=1
17# See merges in log
18enable-commit-graph=1
19enable-log-filecount=1
20enable-log-linecount=1
21enable-tree-linenumbers=1
22enable-subject-links=1
23enable-remote-branches=1
24
25about-filter=filters/about-filter
26source-filter=filters/source-filter
27
28max-repo-count=500
29max-commit-count=50
30
31max-stats=year
32
33noplainemail=0
34
35# Really slow
36#snapshots=tar.gz tar.bz2
37
38readme=master:README
39readme=master:README.md
40readme=master:doc/index.rst
41
42mimetype-file=/etc/mime.types
43
44cache-root=./cache
45cache-size=10000
46cache-dynamic-ttl=1
47cache-repo-ttl=1
48cache-root-ttl=1
49cache-scanrc-ttl=5
50cache-static-ttl=1
51
52enable-git-config=1
53
54# We have a no dumb HTTP clone handled by git-daemon-http
55enable-http-clone=0
56
57project-list=/srv/gitolite/projects.list
58scan-path=/srv/gitolite/repositories/
diff --git a/filters/about-filter b/filters/about-filter
new file mode 120000
index 0000000..11f2be1
--- /dev/null
+++ b/filters/about-filter
@@ -0,0 +1 @@
highlight \ No newline at end of file
diff --git a/filters/highlight b/filters/highlight
new file mode 100755
index 0000000..332a08b
--- /dev/null
+++ b/filters/highlight
@@ -0,0 +1,81 @@
1#!/bin/bash
2#
3# This script can be used to implement syntax highlighting in the cgit
4# tree-view by refering to this file with the source-filter or repo.source-
5# filter options in cgitrc.
6#
7# This script requires a shell supporting the ${var##pattern} syntax.
8# It is supported by at least dash and bash, however busybox environments
9# might have to use an external call to sed instead.
10#
11# Note: the highlight command (http://www.andre-simon.de/) uses css for syntax
12# highlighting, so you'll probably want something like the following included
13# in your css file (generated by highlight 2.4.8 and adapted for cgit):
14#
15# table.blob .num { color:#2928ff; }
16# table.blob .esc { color:#ff00ff; }
17# table.blob .str { color:#ff0000; }
18# table.blob .dstr { color:#818100; }
19# table.blob .slc { color:#838183; font-style:italic; }
20# table.blob .com { color:#838183; font-style:italic; }
21# table.blob .dir { color:#008200; }
22# table.blob .sym { color:#000000; }
23# table.blob .kwa { color:#000000; font-weight:bold; }
24# table.blob .kwb { color:#830000; }
25# table.blob .kwc { color:#000000; font-weight:bold; }
26# table.blob .kwd { color:#010181; }
27#
28# The following environment variables can be used to retrieve the configuration
29# of the repository for which this script is called:
30# CGIT_REPO_URL ( = repo.url setting )
31# CGIT_REPO_NAME ( = repo.name setting )
32# CGIT_REPO_PATH ( = repo.path setting )
33# CGIT_REPO_OWNER ( = repo.owner setting )
34# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
35# CGIT_REPO_SECTION ( = section setting )
36# CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
37
38BASENAME="$1"
39EXTENSION="txt"
40
41[[ "${BASENAME}" != "${BASENAME##*.}" ]] \
42 && EXTENSION="${BASENAME##*.}"
43
44# Static mapping
45case "${BASENAME}" in
46 "Makefile"*) EXTENSION="mk" ;;
47esac
48
49if [[ "${0##*/}" == "about-filter" ]] ; then
50 case "${EXTENSION}" in
51 md)
52 # dev-python/markdown
53 export LC_ALL=en_US.UTF-8
54 exec markdown_py -q \
55 --safe escape \
56 2> /dev/null
57 ;;
58 rst)
59 # dev-python/docutils
60 exec rst2html.py -q \
61 --halt=5 \
62 --no-generator \
63 --pep-references --rfc-references \
64 --template "${0%/*}/templates/rst2html.tmpl" \
65 2> /dev/null
66 ;;
67 *)
68 # Make other source code handled by highlight with no formatting
69 HL_opt="--enclose-pre"
70 ;;
71 esac
72fi
73
74# app-text/highlight
75exec highlight -q \
76 --force --fragment \
77 --include-style \
78 --out-format xhtml \
79 --syntax "${EXTENSION}" \
80 ${HL_opt} \
81 2> /dev/null
diff --git a/filters/source-filter b/filters/source-filter
new file mode 120000
index 0000000..11f2be1
--- /dev/null
+++ b/filters/source-filter
@@ -0,0 +1 @@
highlight \ No newline at end of file
diff --git a/filters/templates/rst2html.tmpl b/filters/templates/rst2html.tmpl
new file mode 100644
index 0000000..43cde42
--- /dev/null
+++ b/filters/templates/rst2html.tmpl
@@ -0,0 +1,4 @@
1%(stylesheet)s
2%(body_pre_docinfo)s
3%(docinfo)s
4%(body)s
diff --git a/logo.png b/logo.png
new file mode 100644
index 0000000..e1cba40
--- /dev/null
+++ b/logo.png
Binary files differ
diff --git a/repos.txt b/repos.txt
new file mode 120000
index 0000000..3b913f9
--- /dev/null
+++ b/repos.txt
@@ -0,0 +1 @@
/srv/gitolite/projects.list \ No newline at end of file