【git】ubuntu12.04 美化gitweb

在之前的文章  http://blog.csdn.net/commshare/article/details/18368695   中,我们安装了一个gitweb,感觉界面很难看啊,firefox比chrome好看一点。

想美化一下:

zhangbin@Ubuntu32:~/alex/gitProject$ pwd
/home/zhangbin/alex/gitProject
zhangbin@Ubuntu32:~/alex/gitProject$ git clone git://github.com/kogakure/gitweb-theme
fatal: could not create work tree dir 'gitweb-theme'.: Permission denied
zhangbin@Ubuntu32:~/alex/gitProject$ sudo git clone git://github.com/kogakure/gitweb-theme
[sudo] password for zhangbin: 
Cloning into 'gitweb-theme'...
remote: Reusing existing pack: 228, done.
Receiving objects: 100% (228/228), 678.89 KiB | 50 KiB/s, done.
Resolving deltas: 100% (69/69), done.
remote: Total 228 (delta 0), reused 0 (delta 0)
zhangbin@Ubuntu32:~/alex/gitProject$ 



看了下 git-theme:http://kogakure.github.io/gitweb-theme/  要求的git版本是1.7.12+的。

Dependencies

git web interface version 1.7.12 (though it may work in older versions, too …)


而我的ubuntu默认是:

root@Ubuntu32:/home/zhangbin/alex/gitProject/gitweb-theme/gitINSTALL/git-1.8.5# git version
git version 1.7.9.5
root@Ubuntu32:/home/zhangbin/alex/gitProject/gitweb-theme/gitINSTALL/git-1.8.5#  

没有css文件。这里我搞错了,其实人家说的是gitweb的版本吧????!!!不是git的!!!!!

后来发现, gitweb是git里头的!!!那就没有错咯!!

=============

git-core当前最新的是1.8.5的git,可以在这里下载https://code.google.com/p/git-core/downloads/detail?name=git-1.8.5.3.tar.gz&can=2&q=


本想参考http://learnhow.no-ip.org/2013/06/12/%E5%9C%A8ubuntu-12-04%E5%AE%89%E8%A3%9D%E6%9C%80%E6%96%B0%E7%89%88%E7%9A%84git/

自己编译一个新版的:

root@Ubuntu32:/home/zhangbin/alex/gitProject/gitweb-theme/gitINSTALL/git-1.8.5# make prefix=/usr all

 make install prefix=/usr all 


也有人说http://stackoverflow.com/questions/14409639/unable-to-update-git-on-ubuntu  要这么装:

wget git-core.googlecode.com/files/git-1.8.1.1.tar.gz
tar -zxf git-1.8.1.1.tar.gz
cd git-1.8.1.1
make prefix=/usr/local all
sudo make prefix=/usr/local install

==============

但是发现更有效的方法是:


root@Ubuntu32:/home/git# whereis git
git: /usr/bin/git /usr/bin/X11/git /usr/share/man/man1/git.1.gz



root@Ubuntu32:/home/git# sudo add-apt-repository ppa:git-core/ppa
You are about to add the following PPA to your system:
 The most current stable version of Git for Ubuntu.


For release candidates, go to https://launchpad.net/~git-core/+archive/candidate .
 More info: https://launchpad.net/~git-core/+archive/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it


gpg: keyring `/tmp/tmpzy9mnU/secring.gpg' created
gpg: keyring `/tmp/tmpzy9mnU/pubring.gpg' created
gpg: requesting key E1DF1F24 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpzy9mnU/trustdb.gpg: trustdb created
gpg: key E1DF1F24: public key "Launchpad PPA for Ubuntu Git Maintainers" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK



root@Ubuntu32:/home/git# sudo apt-get update
Hit http://mirrors.sohu.com precise Release.gpg
Get:1 http://mirrors.sohu.com precise-updates Release.gpg [198 B]              
Hit http://mirrors.sohu.com precise-backports Release.gpg                      
Get:2 http://mirrors.sohu.com precise-security Release.gpg [198 B]             
Hit http://mirrors.sohu.com precise Release                      



                               
root@Ubuntu32:/home/git# apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  git-arch git-cvs git-daemon-run git-email git-gui git-man git-svn gitk
  gitweb libyaml-perl
Suggested packages:
  git-bzr git-mediawiki libyaml-shell-perl
Recommended packages:
  libyaml-libyaml-perl libyaml-syck-perl
The following NEW packages will be installed:
  libyaml-perl
The following packages will be upgraded:
  git git-arch git-cvs git-daemon-run git-email git-gui git-man git-svn gitk
  gitweb
10 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 15.7 MB of archives.
After this operation, 6,887 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libyaml-perl all 0.77-1 [70.4 kB]
Get:2 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git i386 1:1.8.5.2-1~ppa0~precise1 [9,402 kB]
Get:3 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-svn all 1:1.8.5.2-1~ppa0~precise1 [637 kB]
Get:4 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-gui all 1:1.8.5.2-1~ppa0~precise1 [822 kB]
Get:5 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-email all 1:1.8.5.2-1~ppa0~precise1 [562 kB]
Get:6 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-daemon-run all 1:1.8.5.2-1~ppa0~precise1 [543 kB]
Get:7 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-cvs all 1:1.8.5.2-1~ppa0~precise1 [654 kB]
Get:8 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-arch all 1:1.8.5.2-1~ppa0~precise1 [556 kB]
Get:9 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main gitk all 1:1.8.5.2-1~ppa0~precise1 [673 kB]
Get:10 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main git-man all 1:1.8.5.2-1~ppa0~precise1 [1,225 kB]
Get:11 http://ppa.launchpad.net/git-core/ppa/ubuntu/ precise/main gitweb all 1:1.8.5.2-1~ppa0~precise1 [546 kB]
Fetched 15.7 MB in 4min 52s (53.7 kB/s)                                        
(Reading database ... 566732 files and directories currently installed.)
Preparing to replace git 1:1.7.9.5-1 (using .../git_1%3a1.8.5.2-1~ppa0~precise1_i386.deb) ...
Unpacking replacement git ...
Preparing to replace git-svn 1:1.7.9.5-1 (using .../git-svn_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-svn ...
Preparing to replace git-gui 1:1.7.9.5-1 (using .../git-gui_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-gui ...
Preparing to replace git-email 1:1.7.9.5-1 (using .../git-email_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-email ...
Preparing to replace git-daemon-run 1:1.7.9.5-1 (using .../git-daemon-run_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-daemon-run ...
Preparing to replace git-cvs 1:1.7.9.5-1 (using .../git-cvs_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-cvs ...
Preparing to replace git-arch 1:1.7.9.5-1 (using .../git-arch_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-arch ...
Preparing to replace gitk 1:1.7.9.5-1 (using .../gitk_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement gitk ...
Preparing to replace git-man 1:1.7.9.5-1 (using .../git-man_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement git-man ...
Preparing to replace gitweb 1:1.7.9.5-1 (using .../gitweb_1%3a1.8.5.2-1~ppa0~precise1_all.deb) ...
Unpacking replacement gitweb ...
Selecting previously unselected package libyaml-perl.
Unpacking libyaml-perl (from .../libyaml-perl_0.77-1_all.deb) ...
Processing triggers for man-db ...
Setting up git-man (1:1.8.5.2-1~ppa0~precise1) ...
Setting up git (1:1.8.5.2-1~ppa0~precise1) ...
Installing new version of config file /etc/bash_completion.d/git ...
Setting up libyaml-perl (0.77-1) ...
Setting up git-svn (1:1.8.5.2-1~ppa0~precise1) ...
Setting up git-gui (1:1.8.5.2-1~ppa0~precise1) ...
Setting up git-email (1:1.8.5.2-1~ppa0~precise1) ...
Setting up git-daemon-run (1:1.8.5.2-1~ppa0~precise1) ...
Installing new version of config file /etc/sv/git-daemon/run ...
Service git-daemon already added.
ok: run: git-daemon: (pid 14103) 1s
Setting up git-cvs (1:1.8.5.2-1~ppa0~precise1) ...
Setting up git-arch (1:1.8.5.2-1~ppa0~precise1) ...
Setting up gitk (1:1.8.5.2-1~ppa0~precise1) ...
Setting up gitweb (1:1.8.5.2-1~ppa0~precise1) ...


Configuration file `/etc/gitweb.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** gitweb.conf (Y/I/N/O/D/Z) [default=N] ? y
Installing new version of config file /etc/gitweb.conf ...
 * Reloading web server config apache2                                          apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                         [ OK ]
root@Ubuntu32:/home/git# 


替换为新版的gitweb.conf,然后重启apache2:


root@Ubuntu32:/home/git# sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                         [ OK ]
root@Ubuntu32:/home/git# 



=======================按照github的gitweb主题=============

好像直接copy也行:

zhangbin@Ubuntu32:~/alex/gitProject/gitweb-theme$ cp gitweb.css /usr/share/gitweb/static/
cp: cannot create regular file `/usr/share/gitweb/static/gitweb.css': Permission denied
zhangbin@Ubuntu32:~/alex/gitProject/gitweb-theme$ sudo cp gitweb.css /usr/share/gitweb/static/


或者是用这个命令:
zhangbin@Ubuntu32:~/alex/gitProject/gitweb-theme$ sudo ./setup -vi --install
./setup: [NOTICE] - Target not set, using default path: '/usr/share/gitweb'
./setup: 
./setup: Is this ok? [y] | [n] : y
./setup: 
./setup: Backing up original files, continue? [y] | [n] : y
./setup: 
./setup: Backing up...
./setup: 
`/usr/share/gitweb/static/gitweb.css' -> `/usr/share/gitweb/static/gitweb.css.bak'
`/usr/share/gitweb/static/git-favicon.png' -> `/usr/share/gitweb/static/git-favicon.png.bak'
`/usr/share/gitweb/static/git-logo.png' -> `/usr/share/gitweb/static/git-logo.png.bak'
./setup: 
./setup: ...done
./setup: 
./setup: Linking theme files, continue? [y] | [n] : y
./setup: 
./setup: Linking...
./setup: 
`/usr/share/gitweb/static/gitweb.css' -> `/home/zhangbin/alex/gitProject/gitweb-theme/gitweb.css'
`/usr/share/gitweb/static/git-favicon.png' -> `/home/zhangbin/alex/gitProject/gitweb-theme/git-favicon.png'
`/usr/share/gitweb/static/git-logo.png' -> `/home/zhangbin/alex/gitProject/gitweb-theme/git-logo.png'

./setup: 
./setup: ...done
./setup: 
./setup: [NOTICE] - Installation complete!
zhangbin@Ubuntu32:~/alex/gitProject/gitweb-theme$ 


=================即使这样,我的gitweb也不显示css样式啥的,真是无语了===========

改了好久,终于参看这位大牛的文章:http://blog.chinaunix.net/uid-9672747-id-3486257.html


出现的问题在于,apache的gitweb配置中gitweb文件的路径,写错了,gitweb的别名应该指向gitweb文件存放的路径:


【git】ubuntu12.04 美化gitweb_第1张图片


然后apache才会从这里读取gitweb的配置内容。

而之前/var/www下建立gitweb然后指向 /usr/share/gitweb,据说可以不要???是不是呢?


我也按照大牛的配置,把css样式啥的,也改了:

加入了/gitweb/ ,果然有效,估计这个/gitweb就是出现在apache的配置中的那个/gitweb么????好奇怪啊???


【git】ubuntu12.04 美化gitweb_第2张图片



反正现在有了github的风格?

【git】ubuntu12.04 美化gitweb_第3张图片

====================================================

gitweb.conf


# path to git projects (.git)
$projectroot = "/home/zhangbin/alex/gitProject";


# directory to use for temp files
$git_temp = "/tmp";


# target of the home link on top of all pages
#$home_link = $my_uri || "/";


# html text to include at home page
#$home_text = "indextext.html";


# file with project list; by default, simply scan the projectroot dir.
#$projects_list = $projectroot;


# stylesheet to use
@stylesheets = ("/gitweb/static/gitweb.css");


# javascript code for gitweb
$javascript = "/gitweb/static/gitweb.js";


# logo to use
$logo = "/gitweb/static/git-logo.png";


# the 'favicon'
$favicon = "/gitweb/static/git-favicon.png";


# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();
###add by me 
$prevent_xss = 1;
$highlight_bin = "/usr/bin/highlight";
$feature{'highlight'}{'default'} = [1];
$feature{'timed'}{'default'} = [1];
#$feature{'highlight'}{'default'} = [1];



=====

apache的gitweb:

sudo gedit  /etc/apache2/conf.d/gitweb


Alias /gitweb /usr/share/gitweb

  Options FollowSymLinks +ExecCGI
  AddHandler cgi-script .cgi



============ 发现source insight写的中文注释在gitweb里头是乱码,而且有很多\r,难道是因为windows的格式的原因???====

参考 http://blog.mylover.cn/2014/01/%E5%85%B3%E4%BA%8Egitweb%E4%B8%AD%E4%B8%AD%E6%96%87%E6%96%87%E4%BB%B6%E5%90%8D%E4%B9%B1%E7%A0%81%E5%8F%8A%E4%BB%A3%E7%A0%81%E9%AB%98%E4%BA%AE%E7%9A%84%E9%97%AE%E9%A2%98/

关于gitweb中中文文件名乱码及代码高亮的问题

  1. 关于在gitweb中中文文件名乱码的问题

今天突然发现,在gitweb中看到(1)log内中文是正常的,(2)中文目录名是正常的,(3)文件只要是utf-8编码的,中文也是正常的,但如果是中文的文件名,则显示的链接名是正常的,但链接编码却不正常,但前面的中文目录编码是正常的,使得所有指向链接都不对了,主要问题是中文文件名没有转为utf-8编码,解决办法:

把gitweb.cgi中所有 file_name=>”$basedir$t->{‘name’}” 替换为 file_name=>”$basedir” . to_utf8($t->{‘name’}) 即可。

  1. gitweb中代码高亮的问题


关于gitweb中代码的高亮,前提是安装好 highlight,一般已经有了,如果没有,使用 apt-get install highlight 安装即可,但在 gitweb 中默认没有打开这个支持,编辑 /etc/gitweb.conf 文件,在最后面加入一行:$feature{‘highlight’}{‘default’} = [1];

但有些代码还是不支持高亮,比如cs文件,这时可以察看 /usr/share/highlight/langDefs目录下的支持类型,在gitweb.conf中定义highlight_ext的地方,自行添加需要的后缀名就可以了。

======================http://blog.163.com/sunshine_linting/blog/static/44893323201339102723893/

(1)source insight 阅读VC++源码,注释为乱码解决方案

1、options->preferences->Syntax Formatting->Styles;
2、在Style Name 选择 Comment,再对其Font Name 选择Pick,然后再选择“新宋体”。

(2)source insight 阅读Linux源码,注释为乱码解决方案

1、用记事本打开源文件,中文可以显示,另存为,在保存选项中,编码一栏发现是:UTF-8。选在ANSI一项,保存。再用Source Insight 打开,终于可以显示了。


你可能感兴趣的:(linux菜鸟手记,服务器/脚本/编译)