Web front for my code

Haidong Ji 发表于 2018年12月14日 12:48 | Hits: 2719
Tag: Linux | Technology | Web

Awhile ago I set up my own git server. I’ve beenhacking happily using that and Eclipse. In my spare time, I’ve been takingUCSD’s wonderful algorithm course: Algorithmic Design and Techniques. The course provides plenty of programming challenges! I chose the paid version so my code can be evaluated against all tests in the grading server. I solved the programming challenges in 3 languages: Java, Python, and C++. It has been so much fun!

Anyway, I thought it’d be nice to enable aweb front end to my own code hosted on my own server. There are a lot of choices: gitweb, gitlab, gitea, etc. A couple of days agoI came across cgit. It’s pretty lightweight, written in C. That’s what I chose for that task. It’s setup now already, please go tohttps://code.haidongji.comto check it out!

It takes a bit of work to get the clean subdomain working. My environment is Debian 9 running apache2. Below were steps taken to make my environment work. Hope it helps somebody!

  • sudo apt install cgit
    The install creates /etc/cgitrc file and /etc/apache2/conf-available/cgit.conf
  • Here is the content of my apache2 site conf file
    <VirtualHost *:80>
            ServerName code.haidongji.com
            ServerAdmin emailAddress
            DocumentRoot /usr/share/cgit/
    	<Directory "/usr/share/cgit/">
    		AllowOverride None
    		Options ExecCGI
    		Order allow,deny
    		Allow from all
    	Alias /cgit-css/cgit.css /usr/share/cgit/cgit.css
    	Alias /cgit-css/cgit.png /usr/share/cgit/cgit.png
    	ScriptAlias / /usr/lib/cgit/cgit.cgi/
            ErrorLog ${APACHE_LOG_DIR}/codehaidongji.log
            CustomLog ${APACHE_LOG_DIR}/codehaidongji.log combined
  • sudo apt install python3-pygments for syntax highlighting
  • Here is the content of the /etc/cgitrc file
    # enable Pygments syntax highlighting. Must be above scan-path, otherwise it would not work!
  • sudo a2enmod cgid
    sudo a2enconf cgit
  • sudo systemctl restart apache2

Note that in /etc/cgitrc, syntax highlighting line MUST BE ABOVE the scan-path line, otherwise syntax highlighting will not work!

Cheers and happy coding!

原文链接: https://www.haidongji.com/2018/12/13/web-front-for-my-code/

0     +1


可以不填写评论, 而只是打分. 如果发表评论, 你可以给的分值是-5到+5, 否则, 你只能评-1, +1两种分数. 你的评论可能需要审核.


  • +1 guest voted at 2022-12-02 23:50:41