李顺利
随笔-50  评论-170  文章-0  trackbacks-0

程序员的第一篇博客,一般都是Hello World,我也习俗下。

以下用几种方式(Octopress)来贴HelloWorld的代码

  • Backtick Code Blocks
HelloWorld.java
1
2
3
4
5
6
7
8
9
/**
 *
 * @author ShunLi
 */
  public class HelloWorld {
  public static void main(String[] args) {
      System.out.println("Hello World!");
  }
}
  • Include Code Snippets
(HelloWorld.java)download
1
2
3
4
5
6
7
8
9
/**
 *
 * @author ShunLi
 */
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
  • Gist Embedding
  • Inline Code Blocks
1
2
3
4
5
6
7
8
9
/**
 *
 * @author ShunLi
 */
  public class HelloWorld {
  public static void main(String[] args) {
      System.out.println("Hello World!");
  }
}

B.T.W. 我以后应该比较常用Backtick code blocks 和 Include code sinipets.

P.S. 悲催地体验——在Windows下安装Octopress

在Windows下体验Ruby,真的是一件很痛苦的事情,有打算迁移到Ubuntu环境了。 这里记录下载Windows下安装Octopress的步骤,有些真是很痛苦。

  • 安装 ruby 
    如果你不怕麻烦的话,可以选择装ruby+Devkit(Devkit也要安装不然在bundle install这步附近应该会有问题),Windows下安装ruby可以通过RubyInstaller(不过好像经常需要翻Wall过去才能打开),更方便地方法是直接通过
    railsinstaller 来安装,里面包括很多需要的工具。

  • 安装 python 这个真的需要,ruby核心部分有用到。如果没有安装Python的话,在Octopress的代码高亮(include_code 等)部分可能会出现问题: 
    比如:

1
2
3
Liquid error: No such file or directory - python -c import sys; print sys.executable
# or
Liquid error: undefined method `Py_IsInitialized’ for RubyPython::Python:Module

请先安装 python-xxx.msi,然后把python home(e.g. C:\Python27)加到windows环境变量下 
请注意,一定要把python home加到windows环境变量下。

如果还不行的话,请参考这个issue,应该能够解决。

  • 安装octopress 
    这个官网已经有介绍了,应该比较简单。

  • 中文问题
    Windows下如果有中文的话,在generate步骤就会失败,网上给出的解决方法也很简单,就是设置自己本机的环境变量 
     
    具体的就是这样设置的

1
2
set LC_ALL=zh_CN.UTF-8
set LANG=zh_CN.UTF-8
  • 还有一个问题 
    对有序序列支持不好,我已经提了一个
    bug了。

  • 就请欢乐地拥抱Octopress/Jekyll吧。

后记

Octopress 重装记

  1. 参考本文 ,安装ROR,Python并配置好环境配置(中文编码、python)
  2. git clone git@github.com:lishunli/lishunli.github.com.git (change it by yourself)
  3. git checkout source
  4. bundle install or bundle update
  5. rake setup_github_pages
  6. rake generate, rake preview, rake deploy
  7. rake new_post[“title”] 新建的文章默认是ANSI编码的,这会导致generate步骤失败,请转换为UTF-8格式的文件后重新来过,如果还有问题,尝试其它的解决办法。

顺利更新于2012年12月17日



博客中的一些下载已经放到了百度云了,请根据需要下载。【点我去百度云下载】

最后弱弱地说一下,如果可以的话,转载请提供出处( ),谢谢。
posted on 2012-03-18 00:04 李顺利 阅读(7918) 评论(3)  编辑  收藏

评论:
# re: 试用Octopress 2012-03-18 11:43 | 李顺利
@tb
我知道,我只是写一些我自己使用过程中的一些问题,在Windows下,有太多问题了。  回复  更多评论
  
# re: 试用Octopress 2012-03-18 13:57 | liang
不错  回复  更多评论
  
# rake deploy 错误 2013-07-30 11:44 | abdong
d:\GitHub>git clone git://github.com/imathis/octopress.git abdong.github.com
Cloning into 'abdong.github.com'...
remote: Counting objects: 10661, done.
remote: Compressing objects: 100% (5052/5052), done.
remote: Total 10661 (delta 5434), reused 9941 (delta 4748)
Receiving objects: 100% (10661/10661), 2.58 MiB | 39.00 KiB/s, done.
Resolving deltas: 100% (5434/5434), done.

d:\GitHub>cd abdong.github.com


d:\GitHub\abdong.github.com>gem install bundler
Successfully installed bundler-1.3.5
1 gem installed
Installing ri documentation for bundler-1.3.5...
Installing RDoc documentation for bundler-1.3.5...

d:\GitHub\abdong.github.com>bundle install
Fetching source index from http://ruby.taobao.org/


d:\GitHub\abdong.github.com>rake setup_github_pages
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.io)
or 'https://github.com/your_username/your_username.github.io')
Repository url: git@github.com:abdong/abdong.github.com.git
Added remote git@github.com:abdong/abdong.github.com.git as origin

d:\GitHub\abdong.github.com>rake install

d:\GitHub\abdong.github.com>rake new_post["第一篇博客"]

d:\GitHub\abdong.github.com>rake generate


d:\GitHub\abdong.github.com>rake preview


d:\GitHub\abdong.github.com>rake deploy
## Deploying branch to Github Pages
## Pulling any updates from Github Pages
cd _deploy
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
cd -
rm -rf _deploy/index.html

## Copying public to _deploy
cp -r public/. _deploy
cd _deploy

## Commiting: Site updated at 2013-07-30 02:49:26 UTC
[master 37e047c] Site updated at 2013-07-30 02:49:26 UTC
61 files changed, 1118 insertions(+)
.................................................
create mode 100644 stylesheets/screen.css

## Pushing generated _deploy website
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

## Github Pages deploy complete
cd -


请问是什么原因,多谢!~  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: