返回首页
0
0

Web front for my code

Haidong Ji 发表于 2018年12月14日 12:48 | Hits: 1287
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 taking大发排列3注册. 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 tohttp://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
    	</Directory>
    	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
    
    </VirtualHost>
  • sudo apt install python3-pygments for syntax highlighting
  • Here is the content of the /etc/cgitrc file
    css=/cgit-css/cgit.css
    logo=/cgit-css/cgit.png
    
    # enable Pygments syntax highlighting. Must be above scan-path, otherwise it would not work!
    source-filter=/usr/lib/cgit/filters/syntax-highlighting.py
    scan-path=/srv/git
  • 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!

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

0     0

评价列表(0)

返回首页