Browse Source

init

master
Lunny Xiao 4 years ago
commit
bc3dfeb856
63 changed files with 2962 additions and 0 deletions
  1. +7
    -0
      deploy.sh
  2. +15
    -0
      source/lang/en.ini
  3. +15
    -0
      source/lang/zh.ini
  4. BIN
      source/media/author.png
  5. BIN
      source/media/cover.jpg
  6. BIN
      source/media/golang.png
  7. +79
    -0
      source/meta.ini
  8. +9
    -0
      source/page/about.md
  9. +253
    -0
      source/post/2014/1-7-weapons.md
  10. +74
    -0
      source/post/2015/1-xorm-join-extends-usage.md
  11. +7
    -0
      source/post/welcome.md
  12. +26
    -0
      template/default/archive.html
  13. +24
    -0
      template/default/comment.html
  14. +21
    -0
      template/default/footer.html
  15. +24
    -0
      template/default/header.html
  16. +12
    -0
      template/default/meta.html
  17. +32
    -0
      template/default/page.html
  18. +33
    -0
      template/default/post.html
  19. +37
    -0
      template/default/posts.html
  20. +11
    -0
      template/default/static/css/bootstrap.min.css
  21. +8
    -0
      template/default/static/css/prism.css
  22. +281
    -0
      template/default/static/css/style.css
  23. BIN
      template/default/static/favicon.ico
  24. +7
    -0
      template/default/static/js/bootstrap.min.js
  25. +4
    -0
      template/default/static/js/jquery-2.1.4.min.js
  26. +59
    -0
      template/default/static/js/prism.min.js
  27. +2
    -0
      template/default/static/robots.txt
  28. +157
    -0
      template/default/static/sitemap.xsl
  29. +29
    -0
      template/pure/archive.html
  30. +24
    -0
      template/pure/comment.html
  31. +6
    -0
      template/pure/footer.html
  32. +11
    -0
      template/pure/footer_js.html
  33. +14
    -0
      template/pure/meta.html
  34. +15
    -0
      template/pure/page.html
  35. +18
    -0
      template/pure/post.html
  36. +31
    -0
      template/pure/posts.html
  37. +17
    -0
      template/pure/sidebar.html
  38. +245
    -0
      template/pure/static/css/blog.css
  39. +11
    -0
      template/pure/static/css/pure-min.css
  40. +184
    -0
      template/pure/static/css/railscasts.css
  41. BIN
      template/pure/static/favicon.ico
  42. +1
    -0
      template/pure/static/js/highlight.pack.js
  43. +4
    -0
      template/pure/static/js/jquery-2.1.4.min.js
  44. +2
    -0
      template/pure/static/robots.txt
  45. +157
    -0
      template/pure/static/sitemap.xsl
  46. +26
    -0
      template/tpl.md
  47. +24
    -0
      template/uno/archive.html
  48. +24
    -0
      template/uno/comment.html
  49. +27
    -0
      template/uno/cover.html
  50. +11
    -0
      template/uno/footer.html
  51. +8
    -0
      template/uno/footer_js.html
  52. +47
    -0
      template/uno/index.html
  53. +14
    -0
      template/uno/meta.html
  54. +30
    -0
      template/uno/page.html
  55. +33
    -0
      template/uno/post.html
  56. +38
    -0
      template/uno/posts.html
  57. +8
    -0
      template/uno/static/css/prism.css
  58. +484
    -0
      template/uno/static/css/style.css
  59. BIN
      template/uno/static/favicon.ico
  60. +4
    -0
      template/uno/static/js/jquery-2.1.4.min.js
  61. +59
    -0
      template/uno/static/js/prism.min.js
  62. +2
    -0
      template/uno/static/robots.txt
  63. +157
    -0
      template/uno/static/sitemap.xsl

+ 7
- 0
deploy.sh View File

@@ -0,0 +1,7 @@
cp -r $GOPATH/src/github.com/go-xiaohei/pugo/template/ ./template/
pugo build --theme="uno" --dest="$GOPATH/src/github.com/go-xorm/go-xorm.github.io"
cd $GOPATH/src/github.com/go-xorm/go-xorm.github.io
git add --all
git commit -m "updated"
git push origin master
notify "blog updated successfully"

+ 15
- 0
source/lang/en.ini View File

@@ -0,0 +1,15 @@
; navigation
nav.home = Home
nav.archive = Archive
nav.about = About
nav.source = Source
; about post
post.list = All Posts
post.archive = Archives
post.tag = Tags
post.readmore = Read More
; about pagination
pager.prev = Prev
pager.next = Next

+ 15
- 0
source/lang/zh.ini View File

@@ -0,0 +1,15 @@
; navigation
nav.home = 文章
nav.archive = 归档
nav.about = 关于
nav.source = 代码
; about post
post.list = 所有文章
post.archive = 归档
post.tag = 标签
post.readmore = 继续阅读
; about pagination
pager.prev = 更新的
pager.next = 以前的

BIN
source/media/author.png View File

Before After
Width: 256  |  Height: 256  |  Size: 7.4 KiB

BIN
source/media/cover.jpg View File

Before After
Width: 3000  |  Height: 1694  |  Size: 248 KiB

BIN
source/media/golang.png View File

Before After
Width: 340  |  Height: 216  |  Size: 3.7 KiB

+ 79
- 0
source/meta.ini View File

@@ -0,0 +1,79 @@
[meta]
; site title, show in <title>
title = XORM
; subtitle, words after title, in description
subtitle = 官方博客
; print in html <meta>
keyword = golang,orm,xorm
; print in html <meta>
desc = Xorm 是一个简单而强大的Go语言ORM框架
; build links for feed, sitemap
domain = localhost
; root path for site; if empty, build as http://{domain}/
root = http://localhost/
; cover page for homepage
cover = @media/cover.jpg
; global language
lang = zh
; nav data
[nav]
; reference to [home] block, same below.
-:home
-:archive
-:about
[nav.home]
link = /
title = Home
i18n = home
; set nav to active status
hover = home
[nav.archive]
link = /archive
title = Archive
i18n = archive
hover = archive
[nav.about]
link = /about
title = About
i18n = about
; browser open in new tab
; blank = true
hover = about
[nav.source]
link = http://pugo.io
title = Source
i18n = source
blank = true
; author data
[author]
-:pugo
[author.pugo]
name = pugo-robot
email =
url = http://pugo.io
avatar = @media/author.png
bio = the robot of pugo, who generates all default contents.
; comment settings
[comment.disqus]
site = xorm
; build settings
; ignore files to build or copy
[build.ignore]
-:CNAME
-:.git

+ 9
- 0
source/page/about.md View File

@@ -0,0 +1,9 @@
```ini
title = 关于本博客
date = 2014-01-01 16:00:00
tags = go,golang,xorm,orm,sql,database
```
### Introduction
本博客采用[PuGo](github.com/go-xiaohei/pugo)搭建。

+ 253
- 0
source/post/2014/1-7-weapons.md View File

@@ -0,0 +1,253 @@
```ini
title = XORM的七种武器
date = 2014-01-01 16:00:00
tags = go,golang,xorm,orm,sql,database
```

[xorm](https://github.com/lunny/xorm) 是一个简单而强大的 Go 语言开源 ORM 库. 通过它可以使数据库操作非常简便。

# xorm 的七种武器

[xorm](https://github.com/lunny/xorm) 是一个简单而强大的 Go 语言开源 ORM 库. 通过它可以使数据库操作非常简便。

了解过 Go 的人可能会有疑问,Go 已经提供了 database/sql 接口,操作各种数据库接口都一致了,还有必要再使用 ORM 吗?也有人觉得对于复杂 SQL 语句,ORM 是无法应付的。

是的,[xorm](https://github.com/lunny/xorm) 不是为了取代 SQL,它甚至可以和 SQL 混用,它是在 databse/sql 接口的基础之上提供了更多的特性。我们将这些功能和特性比喻成七种武器,来帮助开发者快速的完成数据库的操作。

<!--more-->

## 安装

当然,第一步,我们必须要安装 [xorm](https://github.com/lunny/xorm):

如果你有安装 gopm,强烈建议使用 [gopm](https://github.com/gpmgo/gopm) 来进行 go 的包管理:

gopm get github.com/lunny/xorm

如果没有安装 gopm,当然也可以直接用 go 工具进行安装:

go get github.com/lunny/xorm

## 数据库及驱动支持

[xorm](https://github.com/lunny/xorm) 当前支持如下 5 种数据库驱动和 4 种数据库。

* Mysql: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql)

* MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv)

* SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)

* Postgres: [github.com/lib/pq](https://github.com/lib/pq)

* MsSql: [github.com/lunny/godbc](https://github.com/lunny/godbc)


## 第一种武器:结构体和数据库表的映射

在 [xorm](https://github.com/lunny/xorm) 中,我们用一个结构体和数据库中的表进行对应,结构体中的 field 和数据库中的 column 进行对应,通过在 field 后面的 tag 来进行一些特殊的设置,例如:unique,表示唯一索引;pk 表示主键;version 表示乐观锁字段,等等。写过 sql 语句的同学可能会觉得这些标记很熟悉,是的,大部分和 sql 语句里面的 column 定义类似。

type User struct {
Id int64
Name string `xorm:"unique not null"`
Age int
Avatar []byte
Created time.Time `xorm:"created"`
Updated time.Time `xorm:"updated"`
Version int `xorm:"version"`
}


对应的过程必然涉及到命名的映射。默认的 [xorm](https://github.com/lunny/xorm) 提供了 SnakeMapper,SameMapper, PrefixMapper,
SuffixMapper 几种命名方式和方案,基本可以满足各种需要。

## 第二种武器:连写神技

使用可以连写的 API 对于一个拥有语法提示的编辑器简直就是效率利器,那么我们还有什么理由不支持呢。看看我们这个能写多长:

engine.Where("id=?", 1).And("name = ?", "xlw").Or("age > ?", 20).Asc("name").Desc("id").Find(&users)

[xorm](https://github.com/lunny/xorm) 主要的操作实际上是两个 RAW 函数和七个 ORM 函数:

### RAW 函数

* Query:执行 SQL 查询语句

results, err := engine.Query("select * from user")

* Exec:执行 SQL 执行语句

affected, err := engine.Exec("update user set .... where ...")

### ORM 函数

* Insert:插入一条或多条数据

affected, err := engine.Insert(&struct)
// INSERT INTO struct () values ()
affected, err := engine.Insert(&struct1, &struct2)
// INSERT INTO struct1 () values ()
// INSERT INTO struct2 () values ()
affected, err := engine.Insert(&sliceOfStruct)
// INSERT INTO struct () values (),(),()
affected, err := engine.Insert(&struct1, &sliceOfStruct2)
// INSERT INTO struct1 () values ()
// INSERT INTO struct2 () values (),(),()

* Get:获取单条数据

has, err := engine.Get(&user)
// SELECT * FROM user LIMIT 1

* Find:获取多条数据

err := engine.Find(&users)
// SELECT * FROM user

* Iterate & Rows:获取多条数据并逐条处理

err := engine.Iterate(..., func(...) {
// ...
})
// SELECT * FROM user

rows, err := engine.Rows(...)
// SELECT * FROM user
for rows.Next() {
rows.Scan(&user)
}

* Update:更新一条或多条记录

affected, err := engine.Update(&user)
// UPDATE user SET

* Delete:删除数据

affected, err := engine.Delete(&user)
// DELETE FROM user Where ...

* Count:根据查询条件计算数量

counts, err := engine.Count(&user)
// SELECT count(*) AS total FROM user

这些函数放到连写的最后,前面可以采用各种条件的连写。

## 第三种武器:表结构同步

随着需求的改变,有的时候,我们不得不去修改原有的数据结构,那么此时,我们可能就要去修改数据库的表结构或者索引之类。这是一个繁琐的工作,而且很可能会漏掉之类。通过 [xorm](https://github.com/lunny/xorm) 的 `Sync` 函数,这个工作将变得简单得多。

err := engine.Sync(new(User))

只需要在程序启动时,执行 `Sync`,并将需要同步的一个或者多个表对应的 Struct 作为参数传入,那么 engine 将自动的检测并新增表,新增字段,新增索引。

是不是很简单,很强大。当然,其实也可以做到自动删除列,但是这样的话,很有可能会引起数据丢失,因此当前只提供了自动新增的功能。这个功能后面还会继续增强。

## 第四种武器:混合事务

当使用事务处理时,需要创建 Session 对象。在进行事物处理时,可以混用 ORM 方法和 RAW 方法,如下代码所示:

session := engine.NewSession()
defer session.Close()

// add Begin() before any action
err := session.Begin()
user1 := Userinfo{Username: "xiaoxiao", Departname: "dev", Alias: "lunny"}
_, err = session.Insert(&user1)
if err != nil {
session.Rollback()
return
}

_, err = session.Where("id = ?", 2).Update(&Userinfo{Username: "yyy"})
if err != nil {
session.Rollback()
return
}

_, err = session.Exec("delete from userinfo where username = ?", user2.Username)
if err != nil {
session.Rollback()
return
}

// add Commit() after all actions
err = session.Commit()
if err != nil {
return
}

## 第五种武器:数据库缓存

[xorm](https://github.com/lunny/xorm) 内置了一致性缓存支持,根据测算,开启缓存后,查询性能提高了 3-5 倍。不过缓存默认并没有开启。要开启缓存,需要在engine创建完后进行配置,如:

启用一个全局的内存缓存

cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000)
engine.SetDefaultCacher(cacher)

上述代码采用了 LRU 算法的一个缓存,缓存方式是存放到内存中,缓存 struct 的记录数为 1000 条,缓存针对的范围是所有具有主键的表,没有主键的表中的数据将不会被缓存。
如果只想针对部分表,则:

cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000)
engine.MapCacher(&user, cacher)

如果要禁用某个表的缓存,则:

engine.MapCacher(&user, nil)

设置完之后,其它代码基本上就不需要改动了,缓存系统已经在后台运行。

当前实现了内存存储的 CacheStore 接口 MemoryStore,如果需要采用其它设备存储,可以实现 CacheStore 接口。

不过需要特别注意不适用缓存或者需要手动编码的地方:

* 当使用了 `Distinct`,`Having`,`GroupBy` 方法将不会使用缓存

* 在 `Get` 或者 `Find` 时使用了 `Cols`,`Omit` 方法,则在开启缓存后此方法无效,系统仍旧会取出这个表中的所有字段。

* 在使用 Exec 方法执行了方法之后,可能会导致缓存与数据库不一致的地方。因此如果启用缓存,尽量避免使用 Exec。如果必须使用,则需要在使用了 Exec 之后调用 ClearCache 手动做缓存清除的工作。比如:

engine.Exec("update user set name = ? where id = ?", "xlw", 1)
engine.ClearCache(new(User))

## 第六种武器:乐观锁

很多从事金融软件的朋友都会关注这个问题,乐观锁普遍的在 Java,.Net的ORM框架中被实现。使用如下:

要使用乐观锁,需要使用 version 标记

type User struct {
Id int64
Name string
Version int `xorm:"version"`
}

在 Insert 时,version 标记的字段将会被设置为 1,在 Update 时,Update 的内容必须包含 version 原来的值。

var user User
engine.Id(1).Get(&user)
// SELECT * FROM user WHERE id = ?
engine.Id(1).Update(&user)
// UPDATE user SET ..., version = version + 1 WHERE id = ? AND version = ?

## 第七种武器:数据库反转

现在是不是有点冲动想开始用[ xorm](https://github.com/lunny/xorm) 来管理你的数据库了呢?可以已有数据库怎么处理呢?要重写很多代码吗?

还在羡慕 Java 的 Hibernate 可以通过数据库自动生成 Bean 和 DAO 代码吗?现在 Go 也有了,而且支持生成 c++ 代码,欢呼吧。

[xorm](https://github.com/lunny/xorm) 自带了一个命令行工具,当前提供了反转命令。通过执行

go install github.com/lunny/xorm/xorm

即可安装该工具。安装完成后,我们就可以来使用 `xorm` 这个命令了。[xorm](https://github.com/lunny/xorm) 的反转命令当前支持 sqlite3,mysql,postgres 以及 mssql 四种数据库。命令执行如下:

xorm reverse sqite3 test.db templates/goxorm

其中,第二和第三个参数为数据库驱动的连接参数,最后一个参数为模板路径。对的,你可以在这个模板的基础上进行修改,最后也许你的大部分 models 代码都可以自动生成。我的一个同事已经通过这个工具,生成了一个 Mysql 数据库的 C++ 操作代码。

## 最后

[xorm](https://github.com/lunny/xorm) 项目已经发展了半年多,目前我们已经有两位长期的贡献者,很多同学也给出了各种方面的建议和修正。目前 [xorm](https://github.com/lunny/xorm) 还在不断的成长,欢迎大家多提意见建议贡献代码。

+ 74
- 0
source/post/2015/1-xorm-join-extends-usage.md View File

@@ -0,0 +1,74 @@
```ini
title = 在Xorm中使用Join和Extends标记
date = 2015-12-01 16:00:00
tags = go,golang,xorm,orm,sql,database
```

本文主要针对对Xorm已经有了一定了解的读者,如果您是第一次了解Xorm,请先阅读[xorm操作手册](http://xorm.io/docs)。

Xorm的基本操作都是比较简单的,可能大家也都比较熟悉了。今天主要讲解extends标记和join的使用。通过使用join和extends,可以解决许多需要级联进行的操作。

一般我们会针对数据库中的每一个表,建立一个对应的结构体。比如:
```Go
type User struct {
Id int64
Name string
}

type Account struct {
Id int64
UserId int64 `xorm:"index"`
Amount int64
}

type Car struct {
Id int64
UserId int64 `xorm:"index"`
Type int
}
```

我们定义了三个结构体,对应数据库的三个表,我们在启动时通过:
```Go
engine.Sync2(new(User), new(Account), new(Car))
```
来进行数据库结构的同步。在这个数据库结构中,我们假设一个用户拥有一个Account,一个用户拥有多个Car。

OK。复杂需求来了。

1)我们需要获得所有的用户的姓名和对应的账户的余额:
```Go
type AccountUser struct {
Account `xorm:"extends"`
User `xorm:"extends"`
}

var accounts = make([]*AccountUser, 0)
engine.Table("account").Join("INNER", "user", "account.user_id = user.id").Find(&accounts)
```
OK。这样,我们就取出了user和对应的account,我们通过```account.Account```可以获取到Account的信息,通过```account.User```可以获取到User的信息。

这个是两个表Join,那么如果是三个表也是类似的做法。

2)我只需要用户名,不需要其它的内容:
```Go
type AccountUser struct {
Account `xorm:"extends"`
Name string
}
var accounts = make([]*AccountUser, 0)
engine.Table("account").Join("INNER", "user", "account.user_id = user.id").Find(&accounts)
```
其实我们代码也是差不多的,但是这里我们实际上在查询数据库的时候是查询了user表的所有内容的。只是在最后赋值到结构体时,按需赋值。

3)更复杂的,我们还想知道每人有几辆车。
```Go
type AccountUser struct {
Account `xorm:"extends"`
Name string
NumCars int
}
var accounts = make([]*AccountUser, 0)
engine.Sql("select account.*, user.name, (select count(id) from car where car.user_id = user.id) as num_cars from account, user where account.user_id = user.id").Find(&accounts)
```
在这样的复杂需求下,我们使用了Sql函数和extends标记结合来完成这个操作。

+ 7
- 0
source/post/welcome.md View File

@@ -0,0 +1,7 @@
```ini
title = Xorm博客定型
date = 2015-10-01 16:00:00
tags = go,golang,xorm,orm,sql,database
```
终于迎来了个人认为最有发展潜力的静态站点生成工具 [Pugo](github.com/go-xiaohei/pugo)发布了第一个稳定版本,本博客将使用其搭建,将会发布关于xorm的高质量文章和新版本等信息.

+ 26
- 0
template/default/archive.html View File

@@ -0,0 +1,26 @@
{{template "meta.html" .}}
<body>
{{template "header.html" .}}
<section id="main">
<div class="container">
<div id="archive-list">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
{{range .Archives}}
<div class="archive">
<h3>{{.Year}}</h3>
<hr/>
{{range .Posts}}
<h4>
<span class="date">{{.Created.Month}}.{{.Created.Day}}</span>
<a href="{{url .Url}}">{{.Title}}</a>
</h4>
{{end}}
</div>
{{end}}
</div>
</div>
</div>
</div>
</section>
{{template "footer.html" .}}

+ 24
- 0
template/default/comment.html View File

@@ -0,0 +1,24 @@
{{if .Comment.IsOK}}
<section id="comment">
<div class="row">
<div class="col-md-10 col-md-offset-1">
{{if .Comment.Disqus}}
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = "{{fullUrl .Permalink}}"; // Replace PAGE_URL with your page's canonical URL variable
};
(function () {
var d = document, s = d.createElement('script');
s.src = '//{{.Comment.Disqus.Site}}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments
powered by Disqus.</a></noscript>
{{end}}
</div>
</div>
</section>
{{end}}

+ 21
- 0
template/default/footer.html View File

@@ -0,0 +1,21 @@
<footer id="footer">
<div class="container text-center">
<p>© 2015 {{.Meta.Title}}.
<a href="http://creativecommons.org/licenses/by/3.0/">Some rights reserved </a> |
<a href="{{.Root}}/feed.xml">Feed</a> |
<a href="{{.Root}}/sitemap.xml">Sitemap</a>
</p>
<p>Powered by <a href="https://github.com/go-xiaohei/pugo">PuGo {{.Version.Num}}</a>. Theme by Default.
</p>
</div>
</footer>
<script src="{{.Root}}/static/js/jquery-2.1.4.min.js"></script>
<script src="{{.Root}}/static/js/bootstrap.min.js"></script>
<script src="{{.Root}}/static/js/prism.min.js"></script>
<script>
$(document).ready(function () {
$("pre code").addClass("line-numbers")
});
</script>
</body>
</html>

+ 24
- 0
template/default/header.html View File

@@ -0,0 +1,24 @@
<header id="header">
<div class="container">
<div class="header clearfix">
<nav id="site-nav">
<ul class="nav nav-inverse nav-pills pull-right">{{range .Nav}}
<li role="presentation" class="{{if .IsHover}}active{{end}}{{if .SubNav}} dropdown{{end}}">
<a href="{{url .Link}}" class="{{if .SubNav}} dropdown-toggle{{end}}"{{if .SubNav}} data-toggle="dropdown"{{end}}{{if .IsBlank}} target="_blank" {{end}}>{{if .IconClass}}
<i class="{{.IconClass}}"></i>{{end}}{{.Title}}{{if .SubNav}}<span class="caret"></span>{{end}}
</a>{{if .SubNav}}
<ul class="dropdown-menu">{{range .SubNav}}{{if .IsSeparator}}
<li class="divider"></li>{{else}}
<li><a href="{{url .Link}}"{{if .IsBlank}} target="_blank" {{end}}>{{if .IconClass}}
<i class="{{.IconClass}}"></i>{{end}}{{.Title}}</a>
</li>{{end}}{{end}}
</ul>{{end}}
</li>{{end}}
</ul>
</nav>
<h3 id="site-title">
<a href="{{.Root}}/">{{.Meta.Title}} <sup>{{.Meta.Subtitle}}</sup></a>
</h3>
</div>
</div>
</header>

+ 12
- 0
template/default/meta.html View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>{{.Title}}</title>
<meta name="keywords" content="{{.Meta.Keyword}}"/>
<meta name="description" content="{{.Desc}}"/>
<link rel="stylesheet" href="{{.Root}}/static/css/bootstrap.min.css"/>
<link rel="stylesheet" href="{{.Root}}/static/css/prism.css"/>
<link rel="stylesheet" href="{{.Root}}/static/css/style.css"/>
</head>

+ 32
- 0
template/default/page.html View File

@@ -0,0 +1,32 @@
{{template "meta.html" .}}
<body>
{{template "header.html" .}}
<section id="main">
<div class="container">
<div id="article-single">
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">{{.Page.Created.Month}}</span>
<span class="day">{{.Page.Created.Day}}</span>
</span>
</div>
<h3 class="title">
<a href="{{url .Page.Url}}">{{.Page.Title}}</a>
</h3>
</header>
<aside class="aside clearfix">
<a class="stat label label-default pull-right"{{if .Page.Author.Url}} href="{{.Page.Author.Url}}" target="_blank"{{end}}>{{.Page.Author.Name}}</a>
</aside>
<section class="brief">{{.Page.ContentHTML}}</section>
</div>
</div>
</article>
</div>
{{template "comment.html" .}}
</div>
</section>
{{template "footer.html" .}}

+ 33
- 0
template/default/post.html View File

@@ -0,0 +1,33 @@
{{template "meta.html" .}}
<body>
{{template "header.html" .}}
<section id="main">
<div class="container">
<div id="article-single">
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">{{.Post.Created.Month}}</span>
<span class="day">{{.Post.Created.Day}}</span>
</span>
</div>
<h3 class="title">
<a href="{{url .Post.Url}}">{{.Post.Title}}</a>
</h3>
</header>
<aside class="aside clearfix">{{range .Post.Tags}}
<a class="tag label label-info" href="{{url .Url}}">{{.Name}}</a>{{end}}
<a class="stat label label-default pull-right"{{if .Post.Author.Url}} href="{{.Post.Author.Url}}" target="_blank"{{end}}>{{.Post.Author.Name}}</a>
</aside>
<section class="brief">{{.Post.ContentHTML}}</section>
</div>
</div>
</article>
</div>
{{template "comment.html" .}}
</div>
</section>
{{template "footer.html" .}}

+ 37
- 0
template/default/posts.html View File

@@ -0,0 +1,37 @@
{{template "meta.html" .}}
<body>
{{template "header.html" .}}
<section id="main">
<div class="container">
<div id="article-list">{{if .Tag}}
<h2 class="tag text-center">{{.Tag.Name}}</h2>{{end}}{{range .Posts}}
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">{{.Created.Month}}</span>
<span class="day">{{.Created.Day}}</span>
</span>
</div>
<h3 class="title">
<a href="{{url .Url}}">{{.Title}}</a>
</h3>
</header>
<section class="brief">{{.PreviewHTML}}</section>
<aside class="aside clearfix">
<a class="btn btn-primary btn-lg pull-right" href="{{url .Url}}">{{$.I18n.Tr "post.readmore"}}</a>
</aside>
</div>
</div>
</article>
{{end}}
<div class="article-pager text-center">
{{if .Pager.Prev}}<a class="btn btn-lg btn-info" href="{{url .Pager.PrevUrl}}">{{.I18n.Tr "pager.prev"}}</a>{{end}}
{{if .Pager.Next}}<a class="btn btn-lg btn-info" href="{{url .Pager.NextUrl}}">{{.I18n.Tr "pager.next"}}</a>{{end}}
</div>
</div>
</div>
</section>
{{template "footer.html" .}}

+ 11
- 0
template/default/static/css/bootstrap.min.css
File diff suppressed because it is too large
View File


+ 8
- 0
template/default/static/css/prism.css View File

@@ -0,0 +1,8 @@
/* http://prismjs.com/download.html?themes=prism-coy&languages=markup+css+clike+javascript+actionscript+apacheconf+applescript+aspnet+bash+basic+c+csharp+cpp+coffeescript+css-extras+d+docker+elixir+erlang+fsharp+git+go+groovy+haml+haskell+http+ini+jade+java+julia+latex+less+markdown+matlab+nim+objectivec+perl+php+php-extras+python+r+jsx+ruby+rust+sass+scss+scala+smarty+sql+stylus+swift+typescript+yaml&plugins=line-highlight+line-numbers+show-language+highlight-keywords */
/**
* prism.js Coy theme for JavaScript, CoffeeScript, CSS and HTML
* Based on https://github.com/tshedor/workshop-wp-theme (Example: http://workshop.kansan.com/category/sessions/basics or http://workshop.timshedor.com/category/sessions/basics);
* @author Tim Shedor
*/
code[class*="language-"],pre[class*="language-"]{color:black;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*="language-"]{position:relative;margin:.5em 0;-webkit-box-shadow:-1px 0 0 0 #358ccb,0px 0 0 1px #dfdfdf;-moz-box-shadow:-1px 0 0 0 #358ccb,0px 0 0 1px #dfdfdf;box-shadow:-1px 0 0 0 #358ccb,0px 0 0 1px #dfdfdf;border-left:10px solid #358ccb;background-color:#fdfdfd;background-image:-webkit-linear-gradient(transparent 50%,rgba(69,142,209,0.04) 50%);background-image:-moz-linear-gradient(transparent 50%,rgba(69,142,209,0.04) 50%);background-image:-ms-linear-gradient(transparent 50%,rgba(69,142,209,0.04) 50%);background-image:-o-linear-gradient(transparent 50%,rgba(69,142,209,0.04) 50%);background-image:linear-gradient(transparent 50%,rgba(69,142,209,0.04) 50%);background-size:3em 3em;background-origin:content-box;overflow:visible;max-height:50em;padding:0}code[class*="language"]{max-height:inherit;height:100%;padding:0 1em;display:block;overflow:auto}:not(pre)>code[class*="language-"],pre[class*="language-"]{background-color:#fdfdfd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:1em}:not(pre)>code[class*="language-"]{position:relative;padding:.2em;-webkit-border-radius:.3em;-moz-border-radius:.3em;-ms-border-radius:.3em;-o-border-radius:.3em;border-radius:.3em;color:#c92c2c;border:1px solid rgba(0,0,0,0.1);display:inline}pre[class*="language-"]:before,pre[class*="language-"]:after{content:'';z-index:-2;display:block;position:absolute;bottom:.75em;left:.18em;width:40%;height:20%;-webkit-box-shadow:0 13px 8px #979797;-moz-box-shadow:0 13px 8px #979797;box-shadow:0 13px 8px #979797;-webkit-transform:rotate(-2deg);-moz-transform:rotate(-2deg);-ms-transform:rotate(-2deg);-o-transform:rotate(-2deg);transform:rotate(-2deg)}:not(pre)>code[class*="language-"]:after,pre[class*="language-"]:after{right:.75em;left:auto;-webkit-transform:rotate(2deg);-moz-transform:rotate(2deg);-ms-transform:rotate(2deg);-o-transform:rotate(2deg);transform:rotate(2deg)}.token.comment,.token.block-comment,.token.prolog,.token.doctype,.token.cdata{color:#7d8b99}.token.punctuation{color:#5f6364}.token.property,.token.tag,.token.boolean,.token.number,.token.function-name,.token.constant,.token.symbol,.token.deleted{color:#c92c2c}.token.selector,.token.attr-name,.token.string,.token.char,.token.function,.token.builtin,.token.inserted{color:#2f9c0a}.token.operator,.token.entity,.token.url,.token.variable{color:#a67f59;background:rgba(255,255,255,0.5)}.token.atrule,.token.attr-value,.token.keyword,.token.class-name{color:#1990b8}.token.regex,.token.important{color:#e90}.language-css .token.string,.style .token.string{color:#a67f59;background:rgba(255,255,255,0.5)}.token.important{font-weight:normal}.token.bold{font-weight:bold}.token.italic{font-style:italic}.token.entity{cursor:help}.namespace{opacity:.7}@media screen and (max-width:767px){pre[class*="language-"]:before,pre[class*="language-"]:after{bottom:14px;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}}.token.tab:not(:empty):before,.token.cr:before,.token.lf:before{color:#e0d7d1}pre[class*="language-"].line-numbers{padding-left:0}pre[class*="language-"].line-numbers code{padding-left:3.8em}pre[class*="language-"].line-numbers .line-numbers-rows{left:0}pre[class*="language-"][data-line]{padding-top:0;padding-bottom:0;padding-left:0}pre[data-line] code{position:relative;padding-left:4em}pre .line-highlight{margin-top:0}pre[data-line]{position:relative;padding:1em 0 1em 3em}.line-highlight{position:absolute;left:0;right:0;padding:inherit 0;margin-top:1em;background:hsla(24,20%,50%,.08);background:-moz-linear-gradient(left,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));background:-webkit-linear-gradient(left,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));background:-o-linear-gradient(left,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));background:linear-gradient(left,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));pointer-events:none;line-height:inherit;white-space:pre}.line-highlight:before,.line-highlight[data-end]:after{content:attr(data-start);position:absolute;top:.4em;left:.6em;min-width:1em;padding:0 .5em;background-color:hsla(24,20%,50%,.4);color:hsl(24,20%,95%);font:bold 65%/1.5 sans-serif;text-align:center;vertical-align:.3em;border-radius:999px;text-shadow:none;box-shadow:0 1px white}
.line-highlight[data-end]:after{content:attr(data-end);top:auto;bottom:.4em}pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre.line-numbers>code{position:relative}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}pre[class*='language-']{position:relative}pre[class*='language-'][data-language]::before{content:attr(data-language);color:black;background-color:#cfcfcf;display:inline-block;position:absolute;bottom:auto;left:auto;top:0;right:0;width:auto;height:auto;font-size:.9em;border-radius:0 0 0 5px;padding:0 .5em;text-shadow:none;z-index:1;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-transform:none;-moz-transform:none;-ms-transform:none;-o-transform:none;transform:none}

+ 281
- 0
template/default/static/css/style.css View File

@@ -0,0 +1,281 @@
html, body {
font-family: "PingHei", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Tahoma, Arial, "Hiragino Sans GB", "Hiragino Sans GB W3", "Microsoft YaHei", STXihei, STHeiti, Heiti, SimSun, sans-serif;
}

pre code {
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', "Microsoft Yahei", Helvetica, Arial, sans-serif;
}

body {
padding-top: 24px;
/*background: url("../img/bg.jpg") no-repeat top center;*/
background-color: #FCFCFC;
}

#main {
margin-top: 5em;
}

#site-title {
margin-top: 0;
line-height: 50px;
}

#site-nav {
font-size: 1.2em;
}

#site-nav .nav li a .fa {
margin-right: 6px;
}

#site-title sup {
font-size: 0.5em;
padding-left: 4px;
color: #888;
}

#site-title a {
color: #555;
text-decoration: none;
}

#site-title a:hover {
color: #111;
}

/*#hero*/

#hero {
padding: 5em 5em 6em 5em;
}

#hero-image {
padding: 6px;
background-color: #FFF;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
border-radius: 8px;
}

/*#article-list*/

.article {
margin-bottom: 7em;
position: relative;
}

.article .panel {
padding-left: 30px;
padding-right: 30px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}

.article .panel:hover {
box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2), 0 4px 16px 0 rgba(0, 0, 0, 0.19);
}

.article .header {
position: relative;
margin-bottom: 12px;
border-bottom: 1px dashed #DDD;
}

.article .header .title {
padding-right: 78px;
line-height: 1.5;
}

.article .header a {
color: #444;
}

.article .header a:hover {
color: #0a6ebd;
text-decoration: none;
}

.article .header .meta {
position: absolute;
top: -10px;
right: 0;
}

.article .meta .date {
color: #CCC;
}

.article .meta .date .month {
font-size: 3em;
}

.article .meta .date .day {
vertical-align: top;
font-size: 1.3em;
text-decoration: underline;
margin-top: .6em;
display: inline-block;
}

.article .brief {
line-height: 1.75;
font-size: 16px;
margin-bottom: 18px;
padding-bottom: 12px;
border-bottom: 1px dashed #DDD;
}

.article .brief > *:last-child {
margin-bottom: 0 !important;
}

.article .brief h1 {
font-size: 26px;
border-bottom: 1px dashed #DDD;
padding-bottom: 11.5px;
}

.article .brief h2 {
font-size: 24px;
border-bottom: 1px dashed #DDD;
padding-bottom: 11.5px;
margin-top: 18px;
}

.article .brief h3 {
font-size: 22px;
border-bottom: 1px dashed #DDD;
padding-bottom: 11.5px;
margin-top: 18px;
}

.article .brief h4 {
font-size: 20px;
border-bottom: 1px dashed #DDD;
padding-bottom: 11.5px;
margin-top: 18px;
}

.article .brief h5,
.article .brief h6 {
font-size: 18px;
}

.article .brief h1,
.article .brief h2,
.article .brief h3,
.article .brief h4,
.article .brief h5,
.article .brief h6 {
font-weight: 700;
}

.article .brief img {
max-width: 100%;
}

.article-pager .btn {
font-size: 1.8em;
margin: 0 1em;
}

.article .brief pre code {
font-size: 14px;
}

.article .brief pre {
box-shadow: none !important;
border-top-color: #DDD;
border-right-color: #DDD;
border-bottom-color: #DDD;
}

.article .brief p > code,
.article .brief li > code {
color: #333;
background-color: #f1f1f1;
}

.article .aside .tag {
margin-right: 1em;
font-size: 14px;
}

.article .aside .stat {
font-size: 14px;
}

.article .admin-btn {
position: absolute;
top: -1.4em;
right: -2em;
}

.article .admin-btn .btn {
margin-left: 1em;
}

#article-single .aside {
padding-top: 8px;
border-bottom: 1px dashed #DDD;
padding-bottom: 18px;
margin-bottom: 18px;
}

#article-single .brief {
margin-bottom: 40px;
}

#article-list .aside {
padding-bottom: 24px;
}

#article-list h2.tag {
margin: 0 auto 30px auto;
}

#page-single .article {
margin-bottom: 0;
}

#comment {
margin-top: -4em;
}

/*
#archive-list
*/

#archive-list .panel {
padding: 2em 3em;
}

.archive .date {
margin-right: 1em;
font-size: .8em;
color: #BBB;
display: inline-block;
width: 3em;
}

.archive h4 {
line-height: 40px;
}

/*
#footer
*/

#footer {
font-size: 16px;
color: #CCC;
margin-top: 6em;
margin-bottom: 2em;
}

#footer p {
margin-bottom: .2em;
}

#footer a {
color: #AAA;
}

BIN
template/default/static/favicon.ico View File

Before After

+ 7
- 0
template/default/static/js/bootstrap.min.js
File diff suppressed because it is too large
View File


+ 4
- 0
template/default/static/js/jquery-2.1.4.min.js
File diff suppressed because it is too large
View File


+ 59
- 0
template/default/static/js/prism.min.js
File diff suppressed because it is too large
View File


+ 2
- 0
template/default/static/robots.txt View File

@@ -0,0 +1,2 @@
User-agent: *
Disallow: /static

+ 157
- 0
template/default/static/sitemap.xsl View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,follow" />
<style type="text/css">
body {
font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
font-size:13px;
}
#intro {
background-color:#CFEBF7;
border:1px #2580B2 solid;
padding:5px 13px 5px 13px;
margin:10px;
}
#intro p {
line-height: 16.8667px;
}
#intro strong {
font-weight:normal;
}
td {
font-size:11px;
}
th {
text-align:left;
padding-right:30px;
font-size:11px;
}
tr.high {
background-color:whitesmoke;
}
#footer {
padding:2px;
margin-top:10px;
font-size:8pt;
color:gray;
}
#footer a {
color:gray;
}
a {
color:black;
}
</style>
</head>
<body>
<xsl:apply-templates></xsl:apply-templates>
<div id="footer">
Generated with Google Sitemap Generator Plugin for WordPress. This XSLT template is released under the GPL and free to use.
</div>
</body>
</html>
</xsl:template>
<xsl:template match="sitemap:urlset">
<h1>XML Sitemap</h1>
<div id="intro">
<p>
This is a XML Sitemap which is supposed to be processed by search engines which follow the XML Sitemap standard like Ask.com, Bing, Google and Yahoo.<br />
You can find more information about XML sitemaps on <a rel="external nofollow" href="http://sitemaps.org">sitemaps.org</a>.
</p>
</div>
<div id="content">
<table cellpadding="5">
<tr style="border-bottom:1px black solid;">
<th>URL</th>
<th>Priority</th>
<th>Change frequency</th>
<th>Last modified (GMT)</th>
</tr>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="./sitemap:url">
<tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">high</xsl:attribute>
</xsl:if>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
</td>
<td>
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
</td>
<td>
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:template>
<xsl:template match="sitemap:sitemapindex">
<h1>XML Sitemap Index</h1>
<div id="intro">
<p>
This is a XML Sitemap which is supposed to be processed by search engines which follow the XML Sitemap standard like Ask.com, Bing, Google and Yahoo.<br />
You can find more information about XML sitemaps on <a rel="external nofollow" href="http://sitemaps.org">sitemaps.org</a>.<br />
<br />
This file contains links to sub-sitemaps, follow them to see the actual sitemap content.
</p>
</div>
<div id="content">
<table cellpadding="5">
<tr style="border-bottom:1px black solid;">
<th>URL of sub-sitemap</th>
<th>Last modified (GMT)</th>
</tr>
<xsl:for-each select="./sitemap:sitemap">
<tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">high</xsl:attribute>
</xsl:if>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:template>
</xsl:stylesheet>

+ 29
- 0
template/pure/archive.html View File

@@ -0,0 +1,29 @@
{{template "meta.html" .}}
<div class="pure-g-r" id="layout">
{{template "sidebar.html" .}}
<div class="pure-u-1">
<div class="content">
<div class="page-header">
<h1>{{.I18n.Tr "post.archive"}}</h1>
</div>
{{range .Archives}}
<div class="archive">
<h3>{{.Year}}</h3>
{{range .Posts}}
<ul>
<li>
<h4>
<span class="date">{{.Created.Year}}.{{.Created.Month}}.{{.Created.Day}}</span>
»
<a href="{{url .Url}}">{{.Title}}</a>
</h4>
</li>
</ul>
{{end}}
</div>
{{end}}
</div>
{{template "footer.html" .}}
</div>
</div>
{{template "footer_js.html" .}}

+ 24
- 0
template/pure/comment.html View File

@@ -0,0 +1,24 @@
{{if .Comment.IsOK}}
<div id="comment">
{{if .Comment.Disqus}}
<div id="disqus_thread"></div>
<script>
var disqus_developer = 1;
var disqus_shortname = "{{.Comment.Disqus.Site}}";
var disqus_config = function () {
this.page.url = "{{fullUrl .Permalink}}"; // Replace PAGE_URL with your page's canonical URL variable
};
(function () {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by
Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
{{end}}
</div>
{{end}}

+ 6
- 0
template/pure/footer.html View File

@@ -0,0 +1,6 @@
<hr/>
<div class="footer">
<p>&copy; {{.Meta.Title}} 2015
powered by <a href="http://github.com/go-xiaohei/pugo">PuGo</a> with <a href="http://purecss.io" target="_blank">Pure</a>
</p>
</div>

+ 11
- 0
template/pure/footer_js.html View File

@@ -0,0 +1,11 @@
<script src="/static/js/jquery-2.1.4.min.js"></script>
<script src="/static/js/highlight.pack.js"></script>
<script>
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
</script>
</body>
</html>

+ 14
- 0
template/pure/meta.html View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{.Title}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="{{.Owner.Nick}}">
<meta name="keywords" content="{{.Meta.Keyword}}"/>
<meta name="description" content="{{.Desc}}"/>
<link href="/static/css/pure-min.css" type="text/css" rel="stylesheet" media="all">
<link href="/static/css/blog.css" type="text/css" rel="stylesheet" media="all">
<link href="/static/css/railscasts.css" type="text/css" rel="stylesheet" media="all"/>
</head>
<body>

+ 15
- 0
template/pure/page.html View File

@@ -0,0 +1,15 @@
{{template "meta.html" .}}
<div class="pure-g-r" id="layout">
{{template "sidebar.html" .}}
<div class="pure-u-1">
<div class="content">
<div class="post">
<h1 class="post-header">{{.Page.Title}}</h1>
<div class="post-description">{{.Page.ContentHTML}}</div>
</div>
{{template "comment.html" .}}
</div>
{{template "footer.html" .}}
</div>
</div>
{{template "footer_js.html" .}}

+ 18
- 0
template/pure/post.html View File

@@ -0,0 +1,18 @@
{{template "meta.html" .}}
<div class="pure-g-r" id="layout">
{{template "sidebar.html" .}}
<div class="pure-u-1">
<div class="content">
<div class="post">
<h1 class="post-header">{{.Post.Title}}</h1>
<div class="post-meta">
<small>{{.Post.Created.Year}}-{{.Post.Created.Month}}-{{.Post.Created.Day}}</small>
</div>
<div class="post-description">{{.Post.ContentHTML}}</div>
</div>
{{template "comment.html" .}}
</div>
{{template "footer.html" .}}
</div>
</div>
{{template "footer_js.html" .}}

+ 31
- 0
template/pure/posts.html View File

@@ -0,0 +1,31 @@
{{template "meta.html" .}}
<div class="pure-g-r" id="layout">
{{template "sidebar.html" .}}
<div class="pure-u-1">
<div class="content">
<div class="page-header">
<h1>{{.I18n.Tr "post.list"}}</h1>
</div>
{{if .Tag}}<h2>{{.i18n.Tr "post.tags"}}:{{.Tag.Name}}</h2>{{end}}{{range .Posts}}
<div class="post">
<h3 class="post-header"><a href="{{url .Url}}">{{.Title}}</a></h3>
<div class="post-meta">
<small>{{.Created.Year}}-{{.Created.Month}}-{{.Created.Day}}</small>
</div>
<div class="post-description">{{.PreviewHTML}}</div>
<div class="more">
<a href="{{url .Url}}" class="btn pure-button pure-button-primary">{{$.I18n.Tr "post.readmore"}}..</a>
</div>
</div>
{{end}}
</div>
<div class="pagination pure-g">
<ul>
{{if .Pager.Prev}}<li class="prev pure-u-1-3"><a href="{{url .Pager.PrevUrl}}">← {{.I18n.Tr "pager.prev"}}</a></li>{{end}}
{{if .Pager.Next}}<li class="next pure-u-1-3"><a href="{{url .Pager.NextUrl}}">{{.I18n.Tr "pager.next"}} →</a></li>{{end}}
</ul>
</div>
{{template "footer.html" .}}
</div>
</div>
{{template "footer_js.html" .}}

+ 17
- 0
template/pure/sidebar.html View File

@@ -0,0 +1,17 @@
<div class="sidebar pure-u">
<header class="header">
<hgroup>
<h1 class="brand-title">
<a href="{{.Root}}/" class="brand-title">{{.Meta.Title}}</a>
</h1>
<h2 class="brand-tagline">{{.Meta.Subtitle}}</h2>
</hgroup>
<nav class="nav">
<ul class="nav-list">{{range .Nav}}
<li class="{{if .IsHover}}active{{end}}">{{if .IconClass}}<i class="{{.IconClass}}"></i>{{end}}
<a href="{{url .Link}}"{{if .IsBlank}} target="_blank" {{end}}>{{.Title}}</a>
</li>{{end}}
</ul>
</nav>
</header>
</div>

+ 245
- 0
template/pure/static/css/blog.css View File

@@ -0,0 +1,245 @@
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

a {
text-decoration: none;
color: rgb(142, 142, 214);
}

a:hover, a:focus {
text-decoration: underline;
}

html, body {
font-family: "PingHei", "Lucida Grande", "Lucida Sans Unicode", Helvetica, Tahoma, Arial, "Hiragino Sans GB", "Hiragino Sans GB W3", "Microsoft YaHei", STXihei, STHeiti, Heiti, SimSun, sans-serif;
}

pre code {
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', "Microsoft Yahei", Helvetica, Arial, sans-serif;
}

/* LAYOUT CSS */

#layout {
padding-left: 25%;
/* "left col (nav + list)" width */
position: relative;
}

small {
color: #999;
}

.sidebar {
position: fixed;
top: 0;
bottom: 0;
width: 25%;
margin-left: -25%;
background: rgb(24, 33, 61);
color: #fff;
}

.header {
margin: 50% 2em 0;
text-align: right;
}

.brand-title, .brand-tagline {
margin: 0;
}

.brand-title {
text-transform: uppercase;
color: #fff;
}

.brand-tagline {
margin-top: 20px;
font-weight: 300;
color: rgb(142, 142, 214);
}

.nav {
margin-top: 30px;
}

.nav-list {
margin: 0;
padding: 0;
list-style: none;
}

.nav-list li {
line-height: 30px;
}

.nav-item {
display: inline-block;
zoom: 1;
}

.nav-item a {
background: transparent;
border: 3px solid rgb(103, 103, 180);
color: #fff;
margin-top: 1em;
}

.nav-item a:hover, .nav-item a:focus {
border: 3px solid rgb(142, 142, 214);
color: rgb(142, 142, 214);
text-decoration: none;
}

.content-subhead {
text-transform: uppercase;
color: #aaa;
border-bottom: 1px solid #eee;
padding: 0.4em 0;
font-size: 80%;
font-weight: 500;
letter-spacing: 0.1em;
}

.content {
padding: 2em 3em 0;
}

.post {
padding-bottom: 2em;
}

.post-title {
font-size: 2em;
color: #222;
margin-bottom: 0.2em;
}

.post-avatar {
border-radius: 50px;
float: right;
margin-left: 1em;
}

.post-description {
color: #444;
line-height: 1.5em;
}

.post-meta {
color: #999;
font-size: 85%;
margin: 0;
}

.post-category {
padding: 3px 6px;
margin: 0 0.1em;
background: #eee;
color: #555;
font-size: 80%;
list-style: none;
overflow: hidden;
}

.post-category span {
vertical-align: super;
font-size: 0.8em;
}

.post-images {
margin: 1em 0;
}

.post-image-meta {
margin-top: -3.5em;
margin-left: 1em;
color: #fff;
text-shadow: 0 1px 1px #333;
}

.footer {
text-align: center;
padding: 0 1em;
font-size: 80%
}

@media (max-width: 767px) {
.sidebar {
width: 100%;
position: relative;
margin: 0;
}

.header {
text-align: center;
top: auto;
margin: 3em auto;
position: static;
}

#layout {
padding: 0;
}
}

@media (max-width: 480px) {
.content {
padding: 2em 1em 0;
}
}

.post-category:hover {
background-color: #fff;
border: 1px solid #555;
}

.post-description p > code, .post-description li > code {
margin: 0 2px;
padding: 0 5px;
border: 1px solid #ddd;
background-color: #f8f8f8;
border-radius: 3px;
font-size: 95%;
font-family: Consolas, "Microsoft YaHei", "Courier New", Arial,monospace;
}

.post-description code {
border: 0;
}

.post-description pre {
font-size: 90% !important;
}

.pagination {
width: 100%;
}

.pagination ul {
width: 100%;
text-align: center;
list-style-type: none;
}

.pagination li {
text-align: center;
list-style-type: none;
}

.pagination a {
cursor: pointer;
}

.pagination .disabled {
cursor: default;
}

.archive .date {
display: inline-block;
width: 96px;
}

+ 11
- 0
template/pure/static/css/pure-min.css
File diff suppressed because it is too large
View File


+ 184
- 0
template/pure/static/css/railscasts.css View File

@@ -0,0 +1,184 @@
/*

Railscasts-like style (c) Visoft, Inc. (Damien White)

*/

.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #232323;
color: #e6e1dc;
-webkit-text-size-adjust: none;
}

.hljs-comment,
.hljs-shebang {
color: #bc9458;
font-style: italic;
}

.hljs-keyword,
.ruby .hljs-function .hljs-keyword,
.hljs-request,
.hljs-status,
.nginx .hljs-title,
.method,
.hljs-list .hljs-title {
color: #c26230;
}

.hljs-string,
.hljs-number,
.hljs-regexp,
.hljs-tag .hljs-value,
.hljs-cdata,
.hljs-filter .hljs-argument,
.hljs-attr_selector,
.apache .hljs-cbracket,
.hljs-date,
.tex .hljs-command,
.asciidoc .hljs-link_label,
.markdown .hljs-link_label {
color: #a5c261;
}

.hljs-subst {
color: #519f50;
}

.hljs-tag,
.hljs-tag .hljs-keyword,
.hljs-tag .hljs-title,
.hljs-doctype,
.hljs-sub .hljs-identifier,
.hljs-pi,
.input_number {
color: #e8bf6a;
}

.hljs-identifier {
color: #d0d0ff;
}

.hljs-class .hljs-title,
.hljs-type,
.smalltalk .hljs-class,
.hljs-doctag {
text-decoration: none;
}

.hljs-constant,
.hljs-name {
color: #da4939;
}


.hljs-symbol,
.hljs-built_in,
.ruby .hljs-symbol .hljs-string,
.ruby .hljs-symbol .hljs-identifier,
.asciidoc .hljs-link_url,
.markdown .hljs-link_url,
.hljs-attribute {
color: #6d9cbe;
}

.asciidoc .hljs-link_url,
.markdown .hljs-link_url {
text-decoration: underline;
}



.hljs-params,
.hljs-variable,
.clojure .hljs-attribute {
color: #d0d0ff;
}

.css .hljs-tag,
.hljs-rule .hljs-property,
.hljs-pseudo,
.tex .hljs-special {
color: #cda869;
}

.css .hljs-class {
color: #9b703f;
}

.hljs-rule .hljs-keyword {
color: #c5af75;
}

.hljs-rule .hljs-value {
color: #cf6a4c;
}

.css .hljs-id {
color: #8b98ab;
}

.hljs-annotation,
.apache .hljs-sqbracket,
.nginx .hljs-built_in {
color: #9b859d;
}

.hljs-preprocessor,
.hljs-preprocessor *,
.hljs-pragma {
color: #8996a8 !important;
}

.hljs-hexcolor,
.css .hljs-value .hljs-number {
color: #a5c261;
}

.hljs-title,
.hljs-decorator,
.css .hljs-function {
color: #ffc66d;
}

.diff .hljs-header,
.hljs-chunk {
background-color: #2f33ab;
color: #e6e1dc;
display: inline-block;
width: 100%;
}

.diff .hljs-change {
background-color: #4a410d;
color: #f8f8f8;
display: inline-block;
width: 100%;
}

.hljs-addition {
background-color: #144212;
color: #e6e1dc;
display: inline-block;
width: 100%;
}

.hljs-deletion {
background-color: #600;
color: #e6e1dc;
display: inline-block;
width: 100%;
}

.coffeescript .javascript,
.javascript .xml,
.tex .hljs-formula,
.xml .javascript,
.xml .vbscript,
.xml .css,
.xml .hljs-cdata {
opacity: 0.7;
}

BIN
template/pure/static/favicon.ico View File

Before After

+ 1
- 0
template/pure/static/js/highlight.pack.js
File diff suppressed because it is too large
View File


+ 4
- 0
template/pure/static/js/jquery-2.1.4.min.js
File diff suppressed because it is too large
View File


+ 2
- 0
template/pure/static/robots.txt View File

@@ -0,0 +1,2 @@
User-agent: *
Disallow: /static

+ 157
- 0
template/pure/static/sitemap.xsl View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,follow" />
<style type="text/css">
body {
font-family:"Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana;
font-size:13px;
}
#intro {
background-color:#CFEBF7;
border:1px #2580B2 solid;
padding:5px 13px 5px 13px;
margin:10px;
}
#intro p {
line-height: 16.8667px;
}
#intro strong {
font-weight:normal;
}
td {
font-size:11px;
}
th {
text-align:left;
padding-right:30px;
font-size:11px;
}
tr.high {
background-color:whitesmoke;
}
#footer {
padding:2px;
margin-top:10px;
font-size:8pt;
color:gray;
}
#footer a {
color:gray;
}
a {
color:black;
}
</style>
</head>
<body>
<xsl:apply-templates></xsl:apply-templates>
<div id="footer">
Generated with Google Sitemap Generator Plugin for WordPress. This XSLT template is released under the GPL and free to use.
</div>
</body>
</html>
</xsl:template>
<xsl:template match="sitemap:urlset">
<h1>XML Sitemap</h1>
<div id="intro">
<p>
This is a XML Sitemap which is supposed to be processed by search engines which follow the XML Sitemap standard like Ask.com, Bing, Google and Yahoo.<br />
You can find more information about XML sitemaps on <a rel="external nofollow" href="http://sitemaps.org">sitemaps.org</a>.
</p>
</div>
<div id="content">
<table cellpadding="5">
<tr style="border-bottom:1px black solid;">
<th>URL</th>
<th>Priority</th>
<th>Change frequency</th>
<th>Last modified (GMT)</th>
</tr>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="./sitemap:url">
<tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">high</xsl:attribute>
</xsl:if>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(sitemap:priority*100,'%')"/>
</td>
<td>
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
</td>
<td>
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:template>
<xsl:template match="sitemap:sitemapindex">
<h1>XML Sitemap Index</h1>
<div id="intro">
<p>
This is a XML Sitemap which is supposed to be processed by search engines which follow the XML Sitemap standard like Ask.com, Bing, Google and Yahoo.<br />
You can find more information about XML sitemaps on <a rel="external nofollow" href="http://sitemaps.org">sitemaps.org</a>.<br />
<br />
This file contains links to sub-sitemaps, follow them to see the actual sitemap content.
</p>
</div>
<div id="content">
<table cellpadding="5">
<tr style="border-bottom:1px black solid;">
<th>URL of sub-sitemap</th>
<th>Last modified (GMT)</th>
</tr>
<xsl:for-each select="./sitemap:sitemap">
<tr>
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">high</xsl:attribute>
</xsl:if>
<td>
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(' ', substring(sitemap:lastmod,12,5)))"/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:template>
</xsl:stylesheet>

+ 26
- 0
template/tpl.md View File

@@ -0,0 +1,26 @@
### template documentation

all themes are in this directory.

use specific theme:

$ ./pugo --theme=default

##### theme structure

**including** files:

- meta.html : title, meta, style , etc in `<header>`
- header.html : title, navigator at the top of page
- footer.html : script, copyright at the bottom of page
- comment.html : comment list and form in `post.html` and `page.html`

use `go template syntax` ---- `{{template "meta.html" .}}` to import it.

**major page** files:

- post.html - single post page
- posts.html - posts list page
- archive.html - posts archive page
- page.html - single page template as default. page can set template in meta with `template=xxx.html`
- index.html - homepage template, if not exist, use `posts.html`

+ 24
- 0
template/uno/archive.html View File

@@ -0,0 +1,24 @@
{{template "meta.html" .}}
<body>
{{template "cover.html" .}}
<section id="main">
<div class="container">
<div id="archive-list">
<div class="row">
{{range .Archives}}
<div class="archive">
<h2>{{.Year}}</h2>
{{range .Posts}}
<h4>
<span class="date">{{.Created.Format "01.02"}}</span>
<a href="{{url .Url}}">{{.Title}}</a>
</h4>
{{end}}
</div>
{{end}}
</div>
</div>
{{template "footer.html" .}}
</div>
</section>
{{template "footer_js.html" .}}

+ 24
- 0
template/uno/comment.html View File

@@ -0,0 +1,24 @@
{{if .Comment.IsOK}}
<section id="comment">
<div class="row">
<div class="col-md-10 col-md-offset-1">
{{if .Comment.Disqus}}
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = "{{fullUrl .Permalink}}"; // Replace PAGE_URL with your page's canonical URL variable
};
(function () {
var d = document, s = d.createElement('script');
s.src = '//{{.Comment.Disqus.Site}}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments
powered by Disqus.</a></noscript>
{{end}}
</div>
</div>
</section>
{{end}}

+ 27
- 0
template/uno/cover.html View File

@@ -0,0 +1,27 @@
<aside class="cover {{.PostType}}" style="background: url('{{.Meta.Cover}}') center/cover no-repeat fixed">
<div class="profile">
<a id="avatar-link" title="link to homepage" href="/">
<img src="{{.Owner.Avatar}}" alt="{{.Owner.Nick}}" class="avatar">
<h1 id="profile-title">{{.Meta.Title}}</h1>
</a>
<hr class="divider long">
<p class="bio">
{{.Meta.Subtitle}}<br/>{{.Meta.Desc}}
</p>
<hr class="divider short">
<div class="navigation">
<ul class="nav">{{range .Nav}}
<li role="presentation" class="{{if .IsHover}}active{{end}}">
<a href="{{url .Link}}"{{if .IsBlank}} target="_blank" {{end}}>{{if .IconClass}}
<i class="{{.IconClass}}"></i>{{end}}{{.Title}}
</a>
</li>{{end}}
</ul>
</div>
<ul class="social">
<li><a href="/feed.xml">
<i class="fa fa-rss"></i>
</a></li>
</ul>
</div>
</aside>

+ 11
- 0
template/uno/footer.html View File

@@ -0,0 +1,11 @@
<footer id="footer">
<div class="container text-center">
<p class="left">© 2015 {{.Meta.Title}}.
<a href="http://creativecommons.org/licenses/by/3.0/">Some rights reserved </a> |