Source

o-blog / example / sample-zh.org

Full commit
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
#+TITLE: o-blog
#+DESCRIPTION: 使用 org-mode 的独立博客系统
#+DATE:

#+STARTUP: logdone

#+TEMPLATE_DIR: ../templates
#+LANGUAGE: zh-CN
#+STYLE: style
#+URL: http://exaos.github.com/o-blog

#+DEFAULT_CATEGORY: Tips
#+DISQUS: exaos-o-blog
#+NAME: my-sanitizer
#+begin_src emacs-lisp
(defun el-sanitizer(s)
"Sanitize string S"
(if (equal (ob-sanitize-string s) "")
(md5 s)
(ob-sanitize-string s)))
#+end_src

#+CALL: my-sanitizer()
#+FILENAME_SANITIZER: el-sanitizer

#+POST_BUILD_SHELL: cmd 1
#+POST_BUILD_SHELL: cmd 2
#+POST_BUILD_SHELL: cmd 3
#+POST_BUILD_SHELL: cmd 4

* 快速入门指南
  :PROPERTIES:
  :PAGE:     index.html
  :TEMPLATE: blog_static_no_title.html
  :END:

#+begin_o_blog_row 8

#+HTML: <div class="hero-unit">

#+HTML: <h1>o-blog</h1>

使用 [[http://orgmode.org/][org-mode]] 的独立博客系统。

#+HTML: </div>

#+o_blog_row_column 4

#+HTML: <div class="hero-unit" style="font-size: 200%;">

[[file:{lisp}(ob:path-to-root){/lisp}/features.html][/icon-cog icon-white/ 特性]]

[[https://github.com/renard/o-blog][/icon-github-sign icon-white/ 源代码 (github)]]

[[file:{lisp}(ob:path-to-root){/lisp}/changelog.html][/icon-pencil icon-white/ 更新记录]]

[[file:{lisp}(ob:path-to-root){/lisp}/bug-report.html][/icon-fire icon-white/ Bug report]]


#+HTML: </div>

#+end_o_blog_row


** 设置

首先,你需要安装有 [[http://www.gnu.org/s/emacs][emacs]] (在版本 23 下测试,在 24 下可能也行) 和 [[http://orgmode.org/][org-mode]] (版本
7.8 或更高)。然后你有两种方法可以安装 [[https://github.com/renard/o-blog][o-blog]].

#+begin_o_blog_row 5

#+HTML: <h4>使用 el-get</h4>

要使用 [[https://github.com/dimitri/el-get][el-get]], 安装起来很容易。你所要做的不过是将 =o-blog= 添加到
=el-get-sources= 中,然后执行 =M-x el-get-install o-blog=.

如果你使用 =el-get= 4 或更高,你只需要执行: =M-x el-get-install o-blog=.

#+o_blog_row_column 6

#+html: <h4>手动安装</h4>

首先从 [[http://github.com][Github]] 克隆 /git/ 仓库源码。

#+begin_src bash
cd ~/.emacs.d
git clone https://github.com/renard/o-blog.git
#+end_src

将如下内容添加到你的 =~/.emacs.d/init.el= 文件中:

#+begin_src emacs-lisp
  (add-to-list 'load-path "~/.emacs.d/o-blog")
  (require 'o-blog)
#+end_src

#+end_o_blog_row


** 发布博文

打开文件 =~/.emacs.d/o-blog/example/sample.org= 然后执行 =M-x
org-publish-blog=. 输出的站点默认保存在 =~/.emacs.d/o-blog/out=.

详情参见 [[file:tips/index.html][tips]].

* 博客设置
** Copyright
  :PROPERTIES:
  :SNIPPET:  t
  :END:

Copyright © 2008-2012 [[mailto:seb%2520%E2%9D%A8%C9%91%C6%A6%C9%B5%CF%90%C9%91%CA%82%C9%9B%E2%9D%A9%2520chezwam%2520%E2%9D%A8%C6%A4%C9%B5%C9%A9%C9%B2%CA%88%E2%9D%A9%2520org][Sébastien Gross]]. Published under the therm of the
[[http://creativecommons.org/licenses/by-nc-sa/2.0/fr/][Creative Commons Attribution-Noncommercial-Share Alike 2.0 France License]].

** About
  :PROPERTIES:
  :SNIPPET:  t
  :END:

这是个解释 [[https://github.com/renard/o-blog][o-blog]] 工作机理的博客样例。

** Navigation
  :PROPERTIES:
  :SNIPPET:  t
  :END:

- [[file:{lisp}(ob:path-to-root){/lisp}/features.html][/icon-cog icon-white/ 特性]]

- [[#][/icon-book icon-white/ 文档]]
  - [[file:{lisp}(ob:path-to-root){/lisp}/templates.html][模版]]
  - [[file:{lisp}(ob:path-to-root){/lisp}/structures.html][文档结构]]
  - [[file:{lisp}(ob:path-to-root){/lisp}/functions.html][函数]]
  - 
  - [[file:{lisp}(ob:path-to-root){/lisp}/faq.html][FAQ]]
  - 
  - [[file:{lisp}(ob:path-to-root){/lisp}/bug-report.html][反馈软件缺陷]]

- [[#][/icon-file icon-white/ 近期博文]]
  - [[file:{lisp}(format%20"%25s/%25s"%20(ob:path-to-root)%20(ob:post-htmlfile%20(ob:get-last-post%20"Tips"%200))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 0)){/lisp}]]
  - [[file:{lisp}(format%20"%25s/%25s"%20(ob:path-to-root)%20(ob:post-htmlfile%20(ob:get-last-post%20"Tips"%201))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 1)){/lisp}]]
  - [[file:{lisp}(format%20"%25s/%25s"%20(ob:path-to-root)%20(ob:post-htmlfile%20(ob:get-last-post%20"Tips"%202))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 2)){/lisp}]]
  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 3))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 3)){/lisp}]]
  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 4))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 4)){/lisp}]]

- [[file:{lisp}(ob:path-to-root){/lisp}/tags/index.html][/icon-tags icon-white/ 标签]]

- [[file:{lisp}(ob:path-to-root){/lisp}/archives.html][/icon-list icon-white/ 归档]]

- [[file:{lisp}(ob:path-to-root){/lisp}/index.xml][RSS]]

- [[file:{lisp}(ob:path-to-root){/lisp}/changelog.html][/icon-pencil icon-white/ 更新记录]]

- [[file:{lisp}(ob:path-to-root){/lisp}/debug.html][(调试)]]

** Navigation Footer
   :PROPERTIES:
   :SNIPPET:  t
   :END:   

  - [[file:{lisp}(ob:path-to-root){/lisp}/index.html][/icon-home icon-white/ {lisp}(ob:gettext :home){/lisp}]]

  - [[file:{lisp}(let ((POSTS ALL-POSTS)) (format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (car (ob:get-posts (lambda (x) (equal "Tips" (ob:post-category x)))))))){/lisp}][/icon-file icon-white/ Tips]]

  - [[file:{lisp}(ob:path-to-root){/lisp}/tags/index.html][/icon-tags icon-white/ Tags]]

  - [[file:{lisp}(ob:path-to-root){/lisp}/archives.html][/icon-list icon-white/ Archives]]

  - [[file:{lisp}(ob:path-to-root){/lisp}/index.xml][RSS]]

* 更新记录
  :PROPERTIES:
  :PAGE:     changelog.html
  :END:

- 2012-06-05
  - Update to
    - Font-Awesome 2.0.0-6-g35fca03
    - bootstrap 2.0.4

- 2012-05-21
  - Use responsive bootstrap features.

- 2012-05-07
  - Update to:
    - less.js v1.0-547-ga2df119
  - Bootstrap widgets:
    - label
    - badge
    - progress bar
    - well
    - page header
    - hero unit

- 2012-05-04
  - Update to:
    - bootstrap v2.0.3-5-gb261f97.

- 2012-04-17
  - Update to:
    - less 1.3.0.
    - Font-Awesome v1.0.0-7-g563a6f3.
    - bootstrap v2.0.2-3-g6506ede.

- 2012-04-10
  - Add i18n support.

- 2012-04-06
  - Add org-mode CUSTOM\_ID.

- 2012-03-28
  - Add support for [[http://en.wikipedia.org/wiki/QR_code][QR-code]].

- 2012-03-21
  - 合并上述代码,更新中文演示模版,修改 snippet 为中文。
  - 添加 Disqus 中文讨论。

- 2012-03-20
  - Add [[http://disqus.com][Disqus]] support.
  - User can select the file name sanitizer function.
  - Add [[file:{lisp}(ob:path-to-root){/lisp}/bug-report.html][bug report howto]].

- 2012-03-19
  - 使用 MD5SUM 作为 tags-safe 及 post filename, 解决中文名称的问题 (exaos)

- 2012-03-06
  - Add support for Font-Awesome

- 2012-02-28
  - Switched to bootstrap 2.0.1
  - Switched to lesscss 1.2.2

- 2012-01-23
  - Change tag system from "Tags" to org tagging system.

* 文档
** 调试
   :PROPERTIES:
   :PAGE:     debug.html
   :TEMPLATE: debug.html
   :END:


** 特性
  :PROPERTIES:
  :PAGE:     features.html
  :END:

- 外观
  - 带[[file:{lisp}(ob:path-to-root){/lisp}/debug.html][调试功能]]的动态模版系统 (使用 lisp 函数), 方便嵌入 [[file:{lisp}(ob:path-to-root){/lisp}/bug-report.html][错误报告工具]]
  - 输出的代码片断带有语法加亮
  - 支持 [[http://twitter.github.com/bootstrap/][bootstrap]]
  - 支持 [[http://fortaweso.me/font-awesome/][Font-Awesome]]
  - 支持 [[http://lesscss.org/][lesscss]]
  - 支持 [[http://jquery.com/][JQuery]]
  - 支持 HTML5 / CSS3
- 博客
  - 静态页面 
  - [[file:{lisp}(ob:path-to-root){/lisp}/tags/index.html][云标签]]
  - 多个博客
  - [[file:{lisp}(ob:path-to-root){/lisp}/archives.html][博文归档]]
  - 支持 [[http://disqus.com][Disqus]]
  - 支持 [[http://en.wikipedia.org/wiki/QR_code][QR code]]
- 博文发布
  - 同时支持同步与异步发布
  - 直接发布到网站服务器上 (通过 tramp)
- [[http://twitter.github.com/bootstrap/][Bootstrap]] 额外功能
  - 警告框
  - 支持图标 ([[http://glyphicons.com/][glyphicons]])

** 模版
  :PROPERTIES:
  :PAGE:     templates.html
  :END:

在 [[https://github.com/renard/o-blog][o-blog]] 导出过程中占重头戏的是模版,一组 HTML 的文件。可解析的 Lisp 源码以
=<lisp>= 标签嵌入其中。

#+begin_src html
<h1><lisp>(ob:blog-title BLOG)</lisp></h1>
#+end_src

上面的代码片断可导出为如下类似的内容:

#+begin_src html
<h1>o-blog</h1>
#+end_src

#+begin_o_blog_alert info Information
如果不需要其它模版, [[https://github.com/renard/o-blog][o-blog]] 只用以 =blog_= 打头的模版文件就够了(通过函数
=ob:insert-template= )。

所有其它的模版只是为了方便而定义。
#+end_o_blog_alert


*** 必要的模版

=blog_= 打头的模版。

 - =blog_static.html=: 导出任何静态页面 (函数 =ob-write-static=).
 - =blog_post.html=: 导出一篇博文 (函数 =ob-write-posts=).
 - =blog_tags.html=: 导出云标签页面 (函数 =ob-write-tags=).
 - =blog_tags-detail.html=: 导出匹配特定标签的页面 (函数 =ob-write-tags=).
 - =blog_archive.html=: 导出全部归档 (所有类别、所有年、所有月) 页面 (函数 =ob-write-index=).
 - =blog_rss.html=: 导出 RSS 订阅 (函数 =ob-write-index=).
 - =blog_index_month.html= 导出指定月的索引页面 (函数 =ob-write-index=).
 - =blog_index_year.html= 导出指定月的索引页面 (函数 =ob-write-index=).
 - =blog_index_catery.html= 导出指定类别的索引页面 (函数 =ob-write-index=).

*** 索引模版

以 =index_= 打头的模版。它们使用所有的 =blog_index_*.html= 模版来生成一组匹配指定类别、年、月和全部归档的文章列表。

 - =index_archives.html=
 - =index_category.html=
 - =index_month.html=
 - =index_year.html=

*** 导航模版

以 =nav_= 开头的模版用于生成导航片断:

 - =nav_links.html=: 用于生成用于页首和页尾的的导航菜单。
 - =nav_tag-cloud.html=: 用于生成页尾的云标签。

*** 页面模版

以 =page_= 开头的模版用于生成 HTML 的页头及页尾。


** 结构
  :PROPERTIES:
  :PAGE:     structures.html
  :END:

Some variables are available when publishing lisp parts of templates. These
variables are defined using [[http://www.gnu.org/software/emacs/manual/html_node/cl/Structures.html][defstruct]], then any slot (or property) is
available using a =(type-slot variable)= form.

*** 文档结构

**** Structures: =ob:blog=

Structure used to define a blog:

 - =file=: the blog source file (read-only).
 - =buffer=: buffer visiting the blog file (read-only).
 - =publish-dir=: where to publish the blog defined by the =#+PUBLISH_DIR:=
   header directive or =out= in the same directory as the blog source file.
 - =template-dir=: location of the template directory defined by the
   =#+TEMPLATE_DIR:= header directive or the =templates= directory of the
   =o-blog= library.
 - =style-dir=: path of the /css/ files defined by the =#STYLE_DIR:= header
   directive or =style=. This directory is relative to =template-dir=.
 - =posts-filter=: default filter for post defined by the =#POSTS_FILTER:=
   header directive or =+TODO={DONE}=.
 - =static-filter=: default filter for static pages defined by the
   =#STATIC_FILTER:= header directive or =+PAGES={.*}=.
 - =snippet-filter=  default filter for snippets defined by the
   =#SNIPPET_FILTER:= header directive or =+SNIPPET={.*}=.
 - =title=: Blog title defined by the =#+TITLE:= header directive.
 - =description=: blog description defined by the =#+DESCRIPTION:= header
   directive.
 - =url=: Blog base URL defined by the =#+URL:= header.
 - =default-category=: default category for posts  defined by the
   =#DEFAULT_CATEGORY:= header or =Blog=.
 - =disqus=: [[http://docs.disqus.com/developers/universal/][disqus]] account (called a forum on [[http://disqus.com][Disqus]]) this system
   belongs to. Defined by the \"#DISQUS\" header.
 - =filename-sanitizer=: 1-argument function to be used to sanitize
   post filenames. Defined by =#+FILENAME_SANITIZER:= or
   =ob-sanitize-string=.

Example:

#+begin_src emacs-lisp
;; get the title of the current blog defined in variable BLOG.
(ob:blog-title BLOG)
#+end_src

**** Structures: =ob:post=

 - =id=: the post numerical id. Posts are sort by reversed chronological
   order. The most recent post get the id 0.
 - =title=: the post title read from the entry title.
 - =timestamp=: the post timestamp given by the =CLOSED= property or the
   current time.
 - =year=: numerical year computed from =timestamp=.
 - =month=: numerical month computed from =timestamp=.
 - =day=: numerical day computed from =timestamp=.
 - =category=: category read from =CATEGORY= property org =blog=.
 - =tags=: list of =ob:tags=.
 - =template=: template to use for current post read from =TEMPLATE=
   property or =blog_post.html=.
 - =filepath=: relative path from the blog root directory to the post
   directory (directory only).
 - =filename=: sanitized filename generated from =title=.
 - =htmlfile=: full relative path to the post html file (file and
   directory).
 - =path-to-root=: relative path from the post html file to the blog root.
 - =content=: raw content of the post (org-mode format).
 - =content-html=: HTML export of the post.

Example:

#+begin_src emacs-lisp
;; get the HTML content of the post defined in variable POST.
(ob:post-content-html POST)
#+end_src

**** Structures: =ob:tags=

Structure used to define a tag:

 - =name=: string defying the tag name.
 - =safe=: web safe tag name for URL.
 - =count=: how many time the tag is used.
 - =size=: the font size in percent.

Example:

#+begin_src emacs-lisp
;; get the name of the tag defined in variable TAG.
(ob:tags-name TAG)
#+end_src

*** 变量

Following variables are always available when publishing a blog:

 - =BLOG= (=ob:blog=): information about the blog being published.
 - =POSTS= (list of =ob:post=): list of all posts of the blog or restricted
   list of posts (depending what is exported).
 - =ALL-POSTS=: A copy of =POSTS= except this *always* contents all the
   posts from the blog.
 - =STATIC= (list of =ob:post=): list of static pages.
 - =SNIPPETS= (list of =ob:post=): list of snippets pages.
 - =TAGS= (list of =ob:tags=): list of all tags.

Some variables may be defined in some functions:

 - =POST= (=ob:post=): post (or static page) being currently published.
 - =TAG= (=ob:tags=): tag being currently published.
 - =CATEGORY= (=string=): the category being published.
 - =YEAR=, =MONTH (=integer=): the year and month being published.
 - =PATH-TO-ROOT= (=string=): (intern use only, use =ob:path-to-root=
   instead) path to blog root used by =ob:path-to-root=.

** 函数
  :PROPERTIES:
  :PAGE:     functions.html
  :END:

Basically any lisp function could be used withing a blog template as long as
they are known when exporting. Meanwhile some of them are specifically made
to be used withing templates. These functions are prefixed by =ob:=.

Descriptions are taken from function docstrings.

*** Function: =(ob:get-posts &optional PREDICATE COUNT SORTFUNC COLLECT)=

Return posts (from =POSTS= as defined in =org-publish-blog=) matching
=PREDICATE=. Limit to =COUNT= results if defined and sorted using
=SORTFUNC=.

=PREDICATE= is a function run for each post with the post itself as
argument. If =PREDICATE= is nil, no filter would be done on posts.

=SORTFUNC= is used a =sort= =PREDICATE=.

If =COLLECT= is defined, only returns the =COLLECT= field of a
=ob:post= structure.

Examples:

Getting last 10 posts:

#+begin_src emacs-lisp
   (ob:get-posts nil 10)
#+end_src


Getting post from January 2012:

#+begin_src emacs-lisp
   (ob:get-posts
      (lambda (x)
         (and (= 2012 (ob:post-year x))
              (= 1 (ob:post-month x)))))
#+end_src

Getting all categories:

#+begin_src emacs-lisp
    (ob:get-posts nil nil nil 'category)
#+end_src


**** Template usages

For archive navigation:

#+begin_src html
  <nav id="archives">
    <h1>Archives</h1>
    <ul>
      <lisp>
        (loop for p in (ob:get-posts nil 10)
              do (insert (format "<li><a href=\"%s/%s\">%s</a></li> "
                                 (ob:path-to-root)
                                 (ob:post-htmlfile p)
                                 (ob:post-title p))))
      </lisp>
    </ul>
  </nav>
#+end_src

*** Function: =(ob:get-post-by-id ID)=

Return post which id is =ID=.

**** Template usages

Posts navigation:

#+begin_src html
  <nav class="articles-nav">
    <ul>
      <lisp>
        (progn
          ;; Get previous post
          (let ((ppost (ob:get-post-by-id (1+ (ob:post-id POST)))))
            (if ppost
                (insert (format "<li class=\"prev\"><a href=\"%s/%s\">%s</a></li>"
                                (ob:path-to-root)
                                (ob:post-htmlfile ppost)
                                (ob:post-title ppost)))
              (insert "<li>&nbsp;</li>")))
          ;; Get next post
          (let ((npost (ob:get-post-by-id (1- (ob:post-id POST)))))
            (if npost
                (insert (format "<li class=\"next\"><a href=\"%s/%s\">%s</a></li>"
                                (ob:path-to-root)
                                (ob:post-htmlfile npost)
                                (ob:post-title npost)))
              (insert "<li>&nbsp;</li>"))))
      </lisp>
    </ul>
  </nav>
#+end_src

*** Function: =(ob:get-snippet NAME)=

Get first snippet matching =NAME=.

**** Template usages

Insert the /About/ section in page footer:

#+begin_src html
  <h1>About</h1>
  <address>
    <lisp>(ob:post-content-html (ob:get-snippet "About"))</lisp>
  </address>
#+end_src

*** Function: =(ob:get-header HEADER &optional ALL)=

Get =HEADER= from blog buffer as defined in =BLOG= global context variable.

Returns only fist match except if =ALL= is defined.

**** Template usages

Get the last updated header for rss export:

#+begin_src html
  <updated><lisp>(ob:format-date (ob:get-header "DATE"))</lisp></updated>
#+end_src

*** Function: =(ob:insert-template TEMPLATE)=

Insert =TEMPLATE= in current buffer.

**** Template usages

Insert html header:

#+begin_src html
  <lisp>(ob:insert-template "page_header.html")</lisp>
#+end_src

*** Function: =(ob:format-date DATE &optional FORMAT LOCALE)=

Format =DATE= using =FORMAT= and =LOCALE=.

=DATE= can heither be string suitable for =parse-time-string= or a list of
interger using =current-time= format.

=FORMAT= is a =format-time-string= compatible definition. If not
set ISO8601 =%Y-%m-%dT%TZ= format would be used.

**** Template usages

Add a human readable timestamp for a post:

#+begin_src html
  Posted on <time datetime="<lisp> (ob:format-date (ob:post-timestamp POST)) </lisp>">
    <lisp> (ob:format-date (ob:post-timestamp POST) "%A %B, %d %Y at %H:%M:%S") </lisp>
  </time>.
#+end_src

** 报告软件臭虫 (BUG)
  :PROPERTIES:
  :PAGE:     bug-report.html
  :END:

To report a bug please be sure your issue is =o-blog= related.

You can bootstrap a simple clean environment

#+begin_src sh
rm -rf ~/dev/.emacs.d
mkdir -p ~/dev/.emacs.d
cd ~/dev/.emacs.d
git clone git://github.com/renard/o-blog.git
git clone git://orgmode.org/org-mode.git
#+end_src


Then launch =emacs=:

#+begin_src sh
  cd ~/dev
  rm -rf .emacs.d/o-blog/example/out
  emacs --debug-init -Q  -l .emacs.d/o-blog/sample-init.el --eval \
      '(progn (setq browse-url-generic-program "x-www-browser"
        browse-url-browser-function (quote browse-url-generic))
        (ob-build-sample))'
#+end_src

You can change =x-www-browser= to your favorite browser.

If anything runs fine emacs would exit normally. Otherwise a buffer called
=o-blog Bug-report= is created and its content is copied to primary X
selection (if available). This buffer contains useful information for
debugging your issue. A browser is launch to the [[https://github.com/renard/o-blog/issues/new][o-blog new issue page]]. You
can either paste content of the =o-blog Bug-report= buffer or the X primary
selection (middle click).

Please describe as much as possible your issue (in English). do no hesitate
to paste your blog file to https://gist.github.com/ this might be useful to
debug.



** 问答
  :PROPERTIES:
  :PAGE:     faq.html
  :END:

*** 页面看起来丑丑的~~

Maybe you are using [[https://www.google.com/chrome/][google-chrome]] and try to view your site locally using a
=file:///path/to/your/site/out/index.html= scheme. Open the javascript console
=Ctrl+Shift+I= you should see something like:

如果你使用的是 [[https://www.google.com/chrome/][google-chrome]] 并且用 =file:///path/to/your/site/out/index.html= 这
种方式来查看页面的话,用 =Ctrl+Shift+I= 打开 JavaScript 控制台,你可能会看到如下
类似的提示:

#+begin_example
XMLHttpRequest cannot load file:///path/to/your/site/out/out/style/css/o-blog.less. Cross origin requests are only supported for HTTP.
less-1.2.1.min.js:8Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
#+end_example

这是 Chrome 载入本地 JavaScript 文件时的一个特点,这也是 Chrome 中的一个
/安全特性/ 。

你可以用选项 =--allow-file-access-from-files= 来关闭 Chrome 中的这个特点,或者你可以使用另一个浏览器或者设置一个本地的网页服务器。

有许多复杂的网页服务器解决方案,比如 [[http://nginx.org/][nginx]] 或 [[http://httpd.apache.org/][Apache]] 或许多 [[http://en.wikipedia.org/wiki/Comparison_of_web_server_software][其它的网页服务软件]]。

你可能会优先选择一个轻量级的简单解决方案。

使用 Python, 只需要简单地运行:

#+begin_src sh
cd /path/to/your/site && python -m SimpleHTTPServer
#+end_src

然后浏览 http://localhost:8000

在 Emacs 中你还可以使用 [[https://github.com/jrhbailey/emacs-http-server][emacs-http-server]]:

#+begin_src emacs-lisp
(require 'httpd)
(setq httpd-root "/path/to/your/site")
(httpd-start)
#+end_src

然后浏览 http://localhost:8080

其它的替代方法还有使用 [[http://www.emacswiki.org/emacs/Elnode][elnode]], 但它好象更复杂些。

* Tips
** DONE 创建一个博客条目					  :用例:o@blog:
  CLOSED: [2012-01-07 Sat 00:13]
   :PROPERTIES:
   :CUSTOM_ID: create-new-post
   :END:

A blog consists of org entries. Each entry has a title, some properties and
some text. Exporting a blog means publishing all entries with a =DONE=
=TODO=.

A minimal blog file could be something like:

#+begin_src org

  ,#+TITLE: Lorem ipsum
  ,#+DESCRIPTION: dolor sit amet
  ,#+DATE:

  ,#+STARTUP: logdone

  ,#+URL: http://blog.example.com

  ,* DONE Lorem ipsum
  ,  CLOSED: [2012-01-07 Sat 00:13]
  ,  :PROPERTIES:
  ,  :tags:     Lorem
  ,  :END:

  ,  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
  ,  tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt
  ,  et, mattis eget, convallis nec, purus. Cum sociis natoque penatibus et
  ,  magnis dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec
  ,  vitae dolor. Nullam tristique diam non turpis. Cras placerat accumsan
  ,  nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+end_src

Please note the blank line between the properties section and the text itself.

Use =#+STARTUP: logdone= to automatically add a time stamp when closing an
entry.

** DONE 如何使用标签						  :用例:o@blog:
  CLOSED: [2012-01-07 Sat 00:28]
   :PROPERTIES:
   :CUSTOM_ID: use-tags
   :END:

Tags are useful to classify articles. They are stored as [[http://orgmode.org/manual/Tags.html][org-mode tags]] for
each entries. To add or modify a tag for a post, just use =C-c C-c= and
enter the tag value.

If an article has more than one tag, separate them by a colon (=:=).

Special characters used in tags:

  - At sign (=@=) is converted to a dash (=-=).
  - Underscore (=_=) is converted to a blank (= =).

** DONE 一些 org 语法示例 					     :用例:org:
   CLOSED: [2012-01-07 Sat 11:23]
   :PROPERTIES:
   :CUSTOM_ID: syntax-org-mode
   :END:

*** Titles

This is a level 1

**** Level 2

This is a level 2


***** Level 3

This is a level 3

****** Level 4

This is a level 4

******* Level 5

This is a level 5

******** Level 6

This is a level 6


Up to 6 levels of indentation could be used.

*** Praragaphs

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+html: <div class="two-cols">

Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec
facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis
odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed
bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum,
lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque
condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non
luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce
sagittis, libero non molestie mollis, magna orci ultrices dolor, at
vulputate neque nulla lacinia eros. Sed id ligula quis est convallis
tempor. Curabitur lacinia pulvinar nibh. Nam a sapien.

Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. Etiam vel
tortor sodales tellus ultricies commodo. Suspendisse potenti. Aenean in sem
ac leo mollis blandit. Donec neque quam, dignissim in, mollis nec, sagittis
eu, wisi. Phasellus lacus. Etiam laoreet quam sed arcu. Phasellus at dui in
ligula mollis ultricies. Integer placerat tristique nisl. Praesent
augue. Fusce commodo. Vestibulum convallis, lorem a tempus semper, dui dui
euismod elit, vitae placerat urna tortor vitae lacus. Nullam libero mauris,
consequat quis, varius et, dictum id, arcu. Mauris mollis tincidunt
felis. Aliquam feugiat tellus ut neque. Nulla facilisis, risus a rhoncus
fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit.

#+html: </div>


#+begin_verse
Great clouds overhead
Tiny black birds rise and fall
Snow covers Emacs

-- AlexSchroeder
#+end_verse

#+begin_quote
Everything should be made as simple as possible,
but not any simpler -- Albert Einstein
#+end_quote

#+BEGIN_CENTER
Everything should be made as simple as possible, \\
but not any simpler
#+END_CENTER

*** Lists

As taken from org manual:

My favorite scenes are (in this order)
        1. The attack of the Rohirrim
        2. Eowyn's fight with the witch king
           + this was already my favorite scene in the book
           + I really like Miranda Otto.
        3. Peter Jackson being shot by Legolas
           - on DVD only
           He makes a really funny face when it happens.
But in the end, no individual scenes matter but the film as a whole.
Important actors in this film are:
        - Elijah Wood :: He plays Frodo
        - Sean Austin :: He plays Sam, Frodo's friend.  I still remember
          him very well from his role as Mikey Walsh in The Goonies.

*** Footnotes

The Org homepage[fn:1] now looks a lot better than it used to.

[fn:1] The link is: http://orgmode.org

*** Emphasis and monospace

You can make words *bold*, /italic/, _underlined_, =code= and ~verbatim~,
and, if you must, ‘+strike-through+’. Text in the code and verbatim string
is not processed for Org mode specific syntax; it is exported verbatim.

*** Horizontal rules

A line consisting of only dashes, and at least 5 of them, will be exported
as a horizontal line (‘<hr/>’ in HTML and \hrule in LaTeX).

------

As shown previously.

*** Comment lines

Lines starting with ‘#’ in column zero are treated as comments and will
never be exported. If you want an indented line to be treated as a comment,
start it with ‘#+ ’. Also entire subtrees starting with the word ‘COMMENT’
will never be exported. Finally, regions surrounded by ‘#+BEGIN\_COMMENT’
... ‘#+END\_COMMENT’ will not be exported.

#+begin_comment
C-c ;
Toggle the COMMENT keyword at the beginning of an entry.
#+end_comment

*** Images and Tables

Table

#+CAPTION: This is the caption for the next table (or link)
#+LABEL:   tbl:basic-data
|----------+----------+----------+----------+----------------------------------------------------------------------|
| Header 1 | Header 2 | Header 3 | Header 4 | Header 5                                                             |
|----------+----------+----------+----------+----------------------------------------------------------------------|
|      1.1 |      1.2 |      1.3 | X        | This /cell/ has a *very* =long= ~line~ _with_  _{special} ^{layouts} |
|      2.1 |      2.2 |      3.3 | Y        |                                                                      |
|----------+----------+----------+----------+----------------------------------------------------------------------|
|      3.1 |      3.1 |      C.1 | D.1      | E.1                                                                  |
|----------+----------+----------+----------+----------------------------------------------------------------------|


Image

#+CAPTION: This is the caption for the next figure link (or table)
#+LABEL:   fig:SED-HR4049
[[file:200px-Org-mode-unicorn.svg.png][file:org-mode-unicorn.png]]

*** Literal examples

#+BEGIN_EXAMPLE
Some example from a text file.
#+END_EXAMPLE


Here is an example
        : Some example from a text file.

#+BEGIN_SRC emacs-lisp
  (defun org-xor (a b)
    "Exclusive or."
    (if a (not b) b))
#+END_SRC

#+BEGIN_SRC emacs-lisp -n -r
  (save-excursion                  (ref:sc)
     (goto-char (point-min)))       (ref:jump)
#+END_SRC

In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
jumps to point-min.

*** Special symbols

Angles are written as Greek letters \alpha, \beta and \gamma.

*** Subscripts and superscripts

The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
the sun is R_{sun} = 6.96 x 10^8 m.

*** links

- outsite (page): [[https://github.com/renard/o-blog][/o-blog/ home]].
- [[Creating a blog]]
- insite (file): [[file:o-blog.el]]
- in page (anchor): [[Literal examples]]
** DONE 一些 HTML5 示例						     :html_5:
   CLOSED: [2012-01-10 Tue 20:58]
   :PROPERTIES:
   :CUSTOM_ID: html5-example
   :END:

*** tag: <details>

Works only with chrome.

#+HTML: <details>
#+HTML: <summary>Lorem ipsum dolor sit amet, consectetuer adipiscing elit</summary>
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.
- Sed diam.
- Nam vestibulum accumsan nisl.
#+HTML: </details>

#+begin_src org
  ,#+HTML: <details>
  ,#+HTML: <summary>Lorem ipsum dolor sit amet, consectetuer adipiscing elit</summary>
  ,- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  ,- Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.
  ,- Sed diam.
  ,- Nam vestibulum accumsan nisl.
  ,#+HTML: </details>
#+end_src

** DONE 警告 								 :用例:
   CLOSED: [2012-01-15 Sun 20:40]
   :PROPERTIES:
   :CUSTOM_ID: warning
   :END:

Alerts are declared in =o_blog_alert= blocks. There are 4 types of
them:

 - info
 - success
 - warning
 - error

#+begin_src org
  ,#+begin_o_blog_alert <TYPE> <title>
  ,Text of the alert
  ,#+end_o_blog_alert
#+end_src


#+begin_o_blog_alert error

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+end_o_blog_alert


#+begin_o_blog_alert error Danger

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+end_o_blog_alert

#+begin_o_blog_alert warning Caution

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+end_o_blog_alert



#+begin_o_blog_alert success Tip

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+end_o_blog_alert

#+begin_o_blog_alert info Information

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit
tempor tellus. Donec pretium posuere tellus. Proin quam nisl, tincidunt et,
mattis eget, convallis nec, purus. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Nulla posuere. Donec vitae
dolor. Nullam tristique diam non turpis. Cras placerat accumsan
nulla. Nullam rutrum. Nam vestibulum accumsan nisl.

#+end_o_blog_alert

** DONE 使用 modal 显示源代码 				       :用例:Bootstrap:
   CLOSED: [2012-02-09 Thu 23:13]
   :PROPERTIES:
   :CUSTOM_ID: use-modal
   :END:

The [[http://twitter.github.com/bootstrap/javascript.html#modals][Modal]] bootstrap script can be used to display the content of an external
file in a modal window. The magic line is:

#+begin_src org
  ,#+O_BLOG_SOURCE: path/to/file [mode]
#+end_src

The /org template shorcut/ is =<os= =TAB=. Two parameters might be used:
- The mandatory =/path/to/file= which is the path to the file from which
  content should be read.
- The optional =mode= which could be determined by if omitted.

这是显示 =README-zh.md= 文件的示例:

#+o_blog_source ../README-zh.md markdown

这是显示 elisp 代码的示例:

#+o_blog_source ../sample-init.el emacs-lisp

** DONE 添加图标					       :用例:Bootstrap:
   CLOSED: [2012-02-10 Fri 00:19]
   :PROPERTIES:
   :CUSTOM_ID: add-icons
   :END:

Icons from [[http://glyphicons.com/][glyphicons]] are supported support by simply naming the icon using
italic style:

#+begin_o_blog_row 6


*Source example*

#+begin_src org
  ,/icon-calendar/ calendar
#+end_src

#+o_blog_row_column 6

*Rendered output*

/icon-calendar/ calendar

#+end_o_blog_row



This could also be used for the top /navbar/ using something like:

#+begin_o_blog_row 6

*Source example*

#+begin_src org

  ,- [[#][/icon-book icon-white/ Documentation]]
  ,  - [[file:{lisp}(ob:path-to-root){/lisp}/templates.html][Templates]]
  ,  - [[file:{lisp}(ob:path-to-root){/lisp}/structures.html][Structures]]
  ,  - [[file:{lisp}(ob:path-to-root){/lisp}/functions.html][Functions]]
  ,  -
  ,  - [[file:{lisp}(ob:path-to-root){/lisp}/faq.html][FAQ]]

  ,- [[#][/icon-file icon-white/ Blog]]
  ,  - [[file:{lisp}(format%20"%25s/%25s"%20(ob:path-to-root)%20(ob:post-htmlfile%20(ob:get-last-post%20"Tips"%200))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 0)){/lisp}]]
  ,  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 1))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 1)){/lisp}]]
  ,  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 2))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 2)){/lisp}]]
  ,  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 3))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 3)){/lisp}]]
  ,  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 4))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 4)){/lisp}]]

  ,- [[file:{lisp}(ob:path-to-root){/lisp}/tags/index.html][/icon-tags icon-white/ Tags]]

#+end_src

#+o_blog_row_column 6

*Rendered output*


#+begin_html
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="nav-collapse">
#+end_html

- [[#][/icon-book icon-white/ Documentation]]
  - [[file:{lisp}(ob:path-to-root){/lisp}/templates.html][Templates]]
  - [[file:{lisp}(ob:path-to-root){/lisp}/structures.html][Structures]]
  - [[file:{lisp}(ob:path-to-root){/lisp}/functions.html][Functions]]
  -
  - [[file:{lisp}(ob:path-to-root){/lisp}/faq.html][FAQ]]

- [[#][/icon-file icon-white/ Blog]]
  - [[file:{lisp}(format%20"%25s/%25s"%20(ob:path-to-root)%20(ob:post-htmlfile%20(ob:get-last-post%20"Tips"%200))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 0)){/lisp}]]
  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 1))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 1)){/lisp}]]
  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 2))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 2)){/lisp}]]
  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 3))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 3)){/lisp}]]
  - [[file:{lisp}(format "%s/%s" (ob:path-to-root) (ob:post-htmlfile (ob:get-last-post "Tips" 4))){/lisp}][{lisp}(ob:post-title (ob:get-last-post "Tips" 4)){/lisp}]]

- [[file:{lisp}(ob:path-to-root){/lisp}/tags/index.html][/icon-tags icon-white/ Tags]]

#+begin_html
</div>
</div>
</div>
</div>
#+end_html

Please note the blank line between menu items. if blanks are omitted, the
rendered result might be damaged.

#+end_o_blog_row


** DONE 使用 Bootstrap 分格 				       :用例:Bootstrap:
   CLOSED: [2012-02-10 Fri 01:19]
   :PROPERTIES:
   :CUSTOM_ID: use-bootstrap
   :END:

[[http://twitter.github.com/bootstrap/scaffolding.html][Bootstrap scaffolding]] could be defined using both =#+begin_o_blog_row= and
=#+end_o_blog_row= directives (or =<og= =TAB= shortcut). A new column could
be started using =#+o_blog_row_column= single directive (or =<ogr= =TAB=
shortcut).


#+begin_o_blog_row 6 0 show-grid
*Example*

#+begin_src org
  ,#+begin_o_blog_row 2 -1 show-grid
  ,Column 1
  ,#+o_blog_row_column 2
  ,Column 2
  ,#+end_o_blog_row
#+end_src


#+o_blog_row_column 6

*Output*

#+begin_o_blog_row 2 -1 show-grid

Column 1

#+o_blog_row_column 2

Column 2

#+end_o_blog_row

#+end_o_blog_row


The syntax is:

#+begin_src org
  ,#+begin_o_blog_row SPAN OFFSET GRID-CLASS
  ,Column 1
  ,#+o_blog_row_column SPAN OFFSET
  ,Column 2
  ,...
  ,#+o_blog_row_column SPAN OFFSET
  ,Column n
  ,#+end_o_blog_row

#+end_src

** DONE 中文测试 							 :中文:
   CLOSED: [2012-03-20  09:46]
   - State "DONE"       from ""           [2012-03-20  09:46]
   - State "DONE"       from ""           [2012-03-20  02:19]
   :PROPERTIES:
   :CUSTOM_ID: use-chinese
   :END:

这是一个测试条目哟。

博客页面的文件名默认使用 =ob-sanitize-string= 从标题生成, 这样会导致中文标题的博文无法正常生成。因此,对于中文博客,需要在你的 *org* 文档头中添加
: #+FILENAME_SANITIZER: md5

另外的一个办法就是在文件头添加一段你自己定义的 =emacs-lisp= 代码,比如:
: #+begin_example
: #+NAME: my-sanitizer
: #+begin_src emacs-lisp
: (defun el-sanitizer(s)
:   "Sanitize string S"
:   (if (equal (ob-sanitize-string s) "")
:       (md5 s)
:     (ob-sanitize-string s)))
: #+end_src
: 
: #+CALL: my-sanitizer()
: #+FILENAME_SANITIZER: el-sanitizer
: #+end_example
打开文件后,你需要先将光标移动到 =#+CALL:= 那一行并执行 =C-c C-c=, 然后再执行 =org-publish-blog= 即可。

- 待办事项
  这儿列举了一些中文处理中的问题。具体的解决参见 [[github:exaos/o-blog]].

  1. [X] 中文文件名无法正常生成
     * 现在,使用 =#+FILENAME_SANITIZER: md5= 生成默认为 =YYYY/MM/DD_(MD5).html= 的文件名。
     * 或者在每个条目下添加属性 =CUSTOM_ID=, 生成为 =YYYY/MM/DD_(CUSTOM_ID).html= 形式的文件名。
  2. [X] 博客设置中的 =Copyright=, =About=  =Navigation=  =SNIPPET= 不能用中文的问题。
  3. [X] 多语言模版支持。你需要在文件头中定义 =#+LANGUAGE: zh=, 然后在 =templates/zh= 目录下放置需要翻译成中文的模版文件即可
** DONE 一些 bootstrap 特性				       :用例:Bootstrap:
   CLOSED: [2012-05-03 Thu 21:40]
   :PROPERTIES:
   :CUSTOM_ID: bootstrap-features
   :END:

*** Hero-unit

#+begin_o_blog_row 7

#+BEGIN_SRC org
  ,#+begin_o_blog_hero_unit
  ,#+HTML: <h1>Heading</h1>

  , tagline

  ,#+BEGIN_HTML
  ,    <a class="btn btn-primary btn-large">
  ,      Learn more
  ,    </a>
  ,#+END_HTML
  ,#+end_o_blog_hero_unit
#+END_SRC

#+o_blog_row_column 4

#+begin_o_blog_hero_unit

#+HTML: <h1>Heading</h1>

tagline

#+BEGIN_HTML
    <a class="btn btn-primary btn-large">
      Learn more
    </a>
#+END_HTML
#+end_o_blog_hero_unit

#+end_o_blog_row

*** 页头设置

#+begin_o_blog_row 7

#+BEGIN_SRC org
  ,#+begin_o_blog_page_header
  ,#+HTML: <h1>Page header</h1>
  ,Some text
  ,#+end_o_blog_page_header
#+END_SRC

#+o_blog_row_column 4

#+begin_o_blog_page_header
#+HTML: <h1>Page header</h1>
Some text
#+end_o_blog_page_header

#+end_o_blog_row

*** 使用标注 (label)

    标注及注释文本使用 =label:TYPE= 链接方式,其中的 =TYPE= 可取值为 =default=,
    =success=, =warning=, =important=, =info= 或 =reverse=. 链接的 URL 部分用作标
    注文本。

#+begin_o_blog_row 7

#+BEGIN_SRC txt
   [[ob-label:default][Default]]
   [[ob-label:success][Success]]
   [[ob-label:warning][Warning]]
   [[ob-label:important][Important]]
   [[ob-label:info][Info]]
   [[ob-label:inverse][Inverse]]
#+END_SRC

#+o_blog_row_column 4
   - [[ob-label:default][Default]]
   - [[ob-label:success][Success]]
   - [[ob-label:warning][Warning]]
   - [[ob-label:important][Important]]
   - [[ob-label:info][Info]]
   - [[ob-label:inverse][Inverse]]
#+end_o_blog_row

*** 使用标记 (badges)

    将提示及未读计数当作标注 (label), 使用链接前缀 =badge:TYPE=.

#+begin_o_blog_row 7

#+BEGIN_SRC  text
   [[ob-badge:default][Default]]
   [[ob-badge:success][Success]]
   [[ob-badge:warning][Warning]]
   [[ob-badge:important][Important]]
   [[ob-badge:info][Info]]
   [[ob-badge:inverse][Inverse]]
#+END_SRC

#+o_blog_row_column 4
   - [[ob-badge:default][Default]]
   - [[ob-badge:success][Success]]
   - [[ob-badge:warning][Warning]]
   - [[ob-badge:important][Important]]
   - [[ob-badge:info][Info]]
   - [[ob-badge:inverse][Inverse]]
#+end_o_blog_row

*** 使用进度条

    用于载入、重定向或动作状态。使用链接前缀 =progress:TYPE=, 此处的 =TYPE= 可取
    值 =info=, =success=, =warning= 或 =danger=. 额外的类 (=striped= 或
    =active=) 可用逗号添加。 URL 为进度百分比。

#+begin_o_blog_row 7

#+BEGIN_SRC  text
    [[ob-progress:info][25]]
    [[ob-progress:success,striped][50]]
    [[ob-progress:warning,striped,active][75]]
    [[ob-progress:danger][100]]
#+END_SRC

#+o_blog_row_column 4
    [[ob-progress:info][25]]
    [[ob-progress:success,striped][50]]
    [[ob-progress:warning,striped,active][75]]
    [[ob-progress:danger][100]]
#+end_o_blog_row


*** Well

Use the well as a simple effect on an element to give it an inset effect.

#+begin_o_blog_row 7

#+BEGIN_SRC  text
 , #+begin_o_blog_well
 , Look, I'm in a well!
 , #+end_o_blog_well
#+END_SRC

#+o_blog_row_column 4


#+begin_o_blog_well
Look, I'm in a well!
#+end_o_blog_well

#+end_o_blog_row

** DONE 添加自定义字体					:用例:Bootstrap:o@blog:
   CLOSED: [2012-05-07 Mon 16:38]
   :PROPERTIES:
   :CUSTOM_ID: custom-fonts
   :END:

可在 o-blog 中用两种方式使用 [[http://www.google.com/webfonts][Google webfonts]]:使用 google API 或者在
=templates/style= 目录中提供资源。

#+begin_o_blog_alert warning Caution
使用许多字体样式会让你的页面变得很慢,因此仅选择那些你页面中实际需要的字体样式。
#+end_o_blog_alert

Both example are given using the [[http://www.yanone.de/typedesign/kaffeesatz/][Yanone Kaffeesatz]] font.

*** Using Google API

The [[http://www.google.com/webfonts#QuickUsePlace:quickUse/Family:][quick use]] provides an import snippet such as:

#+BEGIN_SRC css
@import url("http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,200,300,700&subset=latin,latin-ext");
#+END_SRC

That line should be included into the
=templates/style/less/o-blog-default.less= file in which you should also add
something like:

#+BEGIN_SRC css
h1, h2, h3, h4, h5, h6 {
    font-family: "Yanone Kaffeesatz", sans-serif;
}
#+END_SRC

And that's it.

*** Providing resources

That is less efficient in terms of network resources but provide a good
alternative for offline publications.


The script =get-font= does all needed jobs.

#+O_BLOG_SOURCE: ../get-font sh

You can run:

#+BEGIN_SRC sh
./get-font 'http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,200,300,700&subset=latin,latin-ext'
#+END_SRC

And add the font declaration in =templates/style/less/o-blog-default.less=:

#+BEGIN_SRC css
@import "font-Yanone-Kaffeesatz.less";
#+END_SRC

Add declare its use like in the Google API version:

#+BEGIN_SRC css
h1, h2, h3, h4, h5, h6 {
    font-family: "Yanone Kaffeesatz", sans-serif;
}
#+END_SRC
** DONE 创建静态页面					:用例:Bootstrap:o@blog:
   CLOSED: [2012-05-21 Mon 12:48]
   :PROPERTIES:
   :CUSTOM_ID: static-pages
   :END:

#+begin_o_blog_row 7


创建静态页面与创建博文页面一样。你唯一需要做的就是添加属性 =PAGE=. 导出的路径相对
于 =#+PUBLISH_DIR:=.

你也可以为静态页面指定自定义模版,只需添加属性 =TEMPLATE=. 模版路径相对于
=#+TEMPLATE_DIR:=.

#+o_blog_row_column 4

#+BEGIN_SRC org
  ,* Static page
  ,   :PROPERTIES:
  ,   :PAGE:     path/to/static/page.html
  ,   :TEMPLATE: static-page.html
  ,   :END:
#+END_SRC

#+end_o_blog_row