Set a pelican based blog on Ubuntu

Install python-virtualenv:

	sudo apt-get install python-virtualenv

Install the virtualenv Wrapper:

	sudo apt-get install virtualenvwrapper

Now create the directory for holding the virtual environment:

	mkdir ~/pyv

Edit the virtualenv resource file:

	export WORKON_HOME="/home/Trusty/pyv"
	export PROJECT_HOME="/home/Trusty/pyv"
	#source /usr/bin/virtualenvwrapper.sh

Here we meet the problem, it says cannot find the /usr/bin/virtualenvwrapper.sh, I got the answer from the stackoverflow:

	From /usr/share/doc/virtualenvwrapper/README.Debian:
	
	In contrast to the information in
	/usr/share/doc/virtualenvwrapper/en/html/index.html this package installs
	virtualenvwrapper.sh as /etc/bash_completion.d/virtualenvwrapper.
	
	Virtualenvwrapper is enabled if you install the package bash-completion and
	enable bash completion support in /etc/bash.bashrc or your ~/.bashrc.
	
	If you only want to use virtualenvwrapper you may just add
	
	 source /etc/bash_completion.d/virtualenvwrapper
	
	to your ~/.bashrc.

So the right command should be:

	$ cat /home/Trusty/.virtualenvrc 
	export WORKON_HOME="/home/Trusty/pyv"
	export PROJECT_HOME="/home/Trusty/pyv"
	source /etc/bash_completion.d/virtualenvwrapper

Now add this find into .bashrc and source~/.bashrc again:

	$ tail -1 ~/.bashrc 
	source /home/Trusty/.virtualenvrc
	$ source ~/.bashrc	

Good!!! Now you can continue with the following steps, just as we noticed in previous articles.

Update Qzone(2)

Install pinyin for we want to use it for generate the title:

	$ pip install pinyin

Write a new post:

	$ python config_blog.py 迁移博客成功
	content/posts/2014/01/2014_01_24_qianyibokechenggong.md

Chinese codec:

	cat ~/.bashrc
	export LANG="zh_CN.UTF-8"              Or "en_US.UTF-8"
	export LC_ALL="zh_CN.UTF-8"          Or "en_US.UTF-8"

Write the blog:

	vim content/posts/2014/01/2014_01_24_qianyibokechenggong.md

Install BeautifulSoup

	pip install BeautifulSoup

Create a new user for updating qzone

###Backgroud Because github only allow one user to login(trusted key), the error message is listed as “Error: Key already in use”, I have to try another method for updating the qzone.
First I have created a new user on github, and created the corresponding repositories, now I have to create the user on my own machine, named “qzone” for only updating the repository.
###Create the user Use following command for create a new user:

	useradd -m -g root -G wheel -s /bin/bash qzone
	passwd qzone

Then as another oridinary user, run “su qzone” then we can switch to the new user’s shell.
###Configure the user Configure the git tools:

	[qzone@XXXyyy ~]$ git config --global user.name "qzone"
	[qzone@XXXyyy ~]$ git config --global user.email "XXXYYY@qq.com"

Add python virtualenv running environment:

	mkdir ~/pyv
	[qzone@XXXyyy ~]$ cat ~/.virtualenvrc 
	export WORKON_HOME="/home/qzone/pyv"
	export PROJECT_HOME="/home/qzone/pyv"
	source /usr/bin/virtualenvwrapper.sh 	

Add following lines for automatically run virtualenv setup

	$ tail ~/.bashrc
	source /home/qzone/.virtualenvrc

Now we can create the virtualenv for running python.

	[qzone@XXXyyy ~]$ mkvirtualenv --python=/usr/bin/python2.7 v27
	$ cdvirtualenv

Now we are in the python 2.7 environment. But notice you have to set http_proxy/https_proxy, etc for you are working under the proxy.
Install the pelican:

	$ pip install pelican

Add configuration for git proxy:

	export GIT_PROXY_COMMAND=/bin/myproxy

Add workon directory in .bashrc:

	export WORKON_HOME=~/pyv

Next time, workon v27 then we can switch to python2.7 shell.
Make the directory of code, which will store all of the code.

	$ mkdir -p ~/code/XXXYYY

Now clone the existing repository into the local directory:

	git clone https://github.com/XXXYYY/XXXYYY.github.io

Install ghp-import for swiftly deploy your website

	pip install ghp-import

Now setting:

	pelican content -o output -s pelicanconf.py
	ghp-import output
	git push git@github.com:XXXYYY/XXXYYY.github.io.git gh-pages:master

Now you will failed, because you don’t have the correct access rights. So we need to set the ssh access right:

	ssh-keygen -t rsa
	cat ~/.ssh/id_rsa.pub

Then in github’s accounting management page, add this content.
Push all of the modifications to the remote repository:

	git push -f git@github.com:XXXYYY/XXXYYY.github.io.git gh-pages:master

Install markdown for analyse the markdown based blog:

	pip install markdown

Now you can do the following:

	make html
	make github
	git push -f git@github.com:XXXYYY/XXXYYY.github.io.git gh-pages:master

Now install new themes:

	cat pelicanconf.py
	# Use theme for our own
	THEME = "./pelican-themes/waterspill-en"

OK, now you can enjoy the blog finally.

Using pelican for blogging(1)

Getting Start

Install pelican via pip: pip install pelican Getting started Manual: http://docs.getpelican.com/en/3.1.1/getting_started.html, and the command is listed as following:

	# Make sure your pelican is the newest
	$ pip install --upgrade pelican
	$ mkdir ~/code/yoursitename
	$ cd ~/code/yoursitename
	$ pelican-quickstart

The “pelican-quickstart” will ask you some questions, after answer all of the questions, you will have a start-up point for the website.

If your content is OK, run

	$ make html && make serve

will generate the html files and preview it on the server.

Change the Theme

Copy the offical themes into your own directory:

	$ git clone --recursive https://github.com/getpelican/pelican-themes ~/pelican-themes

Set the default theme in your pelicanconf.py:

	# Use theme for our own 
	# THEME = "/home/Trusty/pelican-themes/mnmlist"
	# THEME = "/home/Trusty/pelican-themes/storm"
	THEME = "/home/Trusty/pelican-themes/html5-dopetrope"

Regenerate the site:

	$ make html && make serve

Notice the pelican is pretty slow for rendering all of the content. For some themes, it may take up to several minutes for generating the whole site!

Moving blogs from Qzone to My Own website

Since I’ve wrote blog for more than 7 year, I decide to use my own website to hold all of the articles. So I will start a task for transferring all of the written articles to a new website. Following will be the steps for transferring.
###Which blog system I will use I decide to use static webiste, since the speed is much more faster than the database-based website, and it doesn’t have complicated configuration. Also It’s easy to backup and deploy.
I don’t want to use Octopress, because Octopress is good for recording for technical issues. And Octopress is based on ruby, while I decide to try python based static website generator.
I will choose Hyde. The website for Hyde is located at “http://ringce.com/hyde”, you can get the brief introduction on this website.
###Installation Install hyde directly from yaourt:

	$ yaourt hyde

Or you can directly download the package from the website, and unzip it to a suitable directory, install it.
The most simplest way is via:

	$ pip install hyde

Because my machine runs python3, while hyde currently works under python2, everytime I use hyde, just:

	$ workon venv2
	$ which hyde
	/home/Trusty/.virtualenvs/venv2/bin/hyde

It is recommended that use virtualenv to seperate the hyde environment from other python projects. Refer to “http://hyde.github.io/install”
###Get Demo Site run Create the website:

	$ hyde create

Compile all of the hyde source in the “deploy” directory:

	$ hyde gen

Run a light-weight server enable you to preview the current website $ hyde serve Browser “http://localhost:8080” will see the current website.

After careful consideration, I think maybe I will try hyde later, because a better tool named pelican may fit me better.
“http://blog.getpelican.com/"