forked from blogc/blogc-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.bat
133 lines (112 loc) · 3.73 KB
/
make.bat
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
@ECHO OFF
setlocal EnableDelayedExpansion
REM - Configuration ---------------------------------------------------
set "author_name="Author""
set "author_email="author@example.org""
set "site_title="Site Title""
set "site_tagline="Site Tagline""
set "output_dir=_build"
set "BASE_DOMAIN="http://example.org""
set "BASE_URL="""
set "POST_PER_PAGE=10"
set "POST_PER_PAGE_ATOM=10"
set "DATE_FORMAT="%%b %%d, %%Y, %%I:%%M %%p GMT""
set "DATE_FORMAT_ATOM="%%Y-%%m-%%dT%%H:%%M:%%SZ""
REM - Create output folder --------------------------------------------
rmdir /S /Q %output_dir%
mkdir %output_dir%
REM - Copy assets -----------------------------------------------------
mkdir %output_dir%\assets
xcopy /e assets\* %output_dir%\assets
REM - Post list variables ---------------------------------------------
set posts_list=
for %%i in (content\post\*.txt) do (
set "posts_list=!posts_list! %%i"
)
echo !posts_list!
REM - Generate first index page ---------------------------------------
echo generating first index page
blogc -D AUTHOR_NAME=%author_name% ^
-D AUTHOR_EMAIL=%author_email% ^
-D SITE_TITLE=%site_title% ^
-D SITE_TAGLINE=%site_tagline% ^
-D BASE_DOMAIN=%BASE_DOMAIN% ^
-D BASE_URL=%BASE_URL% ^
-D DATE_FORMAT=%DATE_FORMAT% ^
-D FILTER_PAGE=1 ^
-D FILTER_PER_PAGE=%POST_PER_PAGE% ^
-l -o %output_dir%\index.html -t templates\main.tmpl !posts_list!
REM - Generate post content pages and next index pages ----------------
mkdir %output_dir%\post
set count=
set count_p=1
for %%i in (content\post\*.txt) do (
blogc -D AUTHOR_NAME=%author_name% ^
-D AUTHOR_EMAIL=%author_email% ^
-D SITE_TITLE=%site_title% ^
-D SITE_TAGLINE=%site_tagline% ^
-D BASE_DOMAIN=%BASE_DOMAIN% ^
-D BASE_URL=%BASE_URL% ^
-D DATE_FORMAT=%DATE_FORMAT% ^
-D FILTER_PAGE=1 ^
-D FILTER_PER_PAGE=%POST_PER_PAGE% ^
-D IS_POST=1 ^
-o %output_dir%\post\%%~ni\index.html -t templates\main.tmpl %%i
set /a count += 1
echo post page: !count!
REM - Generate next index page ------------------------------------
if !count_p!==!count! (
echo index page: !count_p!
blogc -D AUTHOR_NAME=%author_name% ^
-D AUTHOR_EMAIL=%author_email% ^
-D SITE_TITLE=%site_title% ^
-D SITE_TAGLINE=%site_tagline% ^
-D BASE_DOMAIN=%BASE_DOMAIN% ^
-D BASE_URL=%BASE_URL% ^
-D DATE_FORMAT=%DATE_FORMAT% ^
-D FILTER_PAGE=1 ^
-D FILTER_PER_PAGE=%POST_PER_PAGE% ^
-l -o %output_dir%\page\1\index.html -t templates\main.tmpl !posts_list!
)
if !count!==%POST_PER_PAGE% (
echo index page: !count_p!
blogc -D AUTHOR_NAME=%author_name% ^
-D AUTHOR_EMAIL=%author_email% ^
-D SITE_TITLE=%site_title% ^
-D SITE_TAGLINE=%site_tagline% ^
-D BASE_DOMAIN=%BASE_DOMAIN% ^
-D BASE_URL=%BASE_URL% ^
-D DATE_FORMAT=%DATE_FORMAT% ^
-D FILTER_PAGE=!count_p! ^
-D FILTER_PER_PAGE=%POST_PER_PAGE% ^
-l -o %output_dir%\page\!count_p!\index.html -t templates\main.tmpl !posts_list!
set /a count_p += 1
set count=
)
)
REM - Generate other pages --------------------------------------------
set count=1
for %%i in (content\*.txt) do (
echo other page: !count!
blogc -D AUTHOR_NAME=%author_name% ^
-D AUTHOR_EMAIL=%author_email% ^
-D SITE_TITLE=%site_title% ^
-D SITE_TAGLINE=%site_tagline% ^
-D BASE_DOMAIN=%BASE_DOMAIN% ^
-D BASE_URL=%BASE_URL% ^
-D DATE_FORMAT=%DATE_FORMAT% ^
-o %output_dir%\%%~ni.html -t templates\main.tmpl %%i
set /a count += 1
)
REM - Generate atom rss ----------------------------------------------
echo generating atom rss
blogc -D AUTHOR_NAME=%author_name% ^
-D AUTHOR_EMAIL=%author_email% ^
-D SITE_TITLE=%site_title% ^
-D SITE_TAGLINE=%site_tagline% ^
-D BASE_DOMAIN=%BASE_DOMAIN% ^
-D BASE_URL=%BASE_URL% ^
-D DATE_FORMAT=%DATE_FORMAT_ATOM% ^
-D FILTER_PAGE=1 ^
-D FILTER_PER_PAGE=%POST_PER_PAGE_ATOM% ^
-l -o %output_dir%\atom.xml -t templates\atom.tmpl !posts_list!