Butingtaon's Corner

Posts by type
Other

CGit

CGit is a read-only web frontend for publishing git repositories, written in the C language running as a Common Gateway Interface program.

I've decided to set up CGit on my blog to have a central place to store my code on the internet that is not Github that I also directly manage, if not entirely self-host. The core functionality was pretty easy to get set up, but the default theme is a bit too harsh on the eyes.

There are a few files that I needed to tweak:

  • /cgit/cgit.css
  • /cgit/local/lib/cgit/filters/syntax-highlighting.py
  • /cgit/local/lib/cgit/filters/html-converters/md2html

I've been using the Dracula Theme on my memex so it makes sense to use it for my code repository as well.

This is the one that needs the most work. What I did to make the theming easier is to replace the default CSS with the one from jbauer's config which makes use of CSS Variables allowing certain colors to be easily replaced with the chosen theme colors.

After replacing the CSS file, then comes the tedious task of applying the theme colors one by one.

This one is significantly easier. This is a python source file, look for the line that starts with formatter and change the style parameter value to dracula

It should look something like this:

formatter = HtmlFormatter(style='dracula', nobackground=True)
		

This is another python file. This includes a sys.stdout.write function call that includes an entire <style> tag which we would need to treat like cgit.css file