forked from ArtalkJS/Artalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-example-site.sh
executable file
·178 lines (147 loc) · 5.57 KB
/
setup-example-site.sh
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
#!/bin/bash
#
# This script sets up a local example site for testing,
# with Artalk integrated.
# Build frontend and backend before running this script.
# After running this script, run:
# ./bin/artalk server -c ./local/local.yml
# to start the comment server.
# And open http://localhost:1313/ in your browser to view the example site.
#
# exit if any command fails
set -e
# check if hugo is installed
if ! [ -x "$(command -v hugo)" ]; then
echo 'Error: hugo is not installed.' >&2
exit 1
fi
# check if ./public/dist/Artalk.css exists
if ! [ -f "./public/dist/Artalk.css" ]; then
echo 'Error: ./public/dist/Artalk.css does not exist.' >&2
exit 1
fi
mkdir -p ./local
# copy internal/query/testdata/example_site_conf.yml to ./local/local.yml if it does not exist
if ! [ -f "./local/artalk.yml" ]; then
echo "Copying internal/query/testdata/example_site_conf.yml to ./local/artalk.yml"
cp ./internal/query/testdata/example_site_conf.yml ./local/local.yml
fi
# clean up local/example_site if it exists
if [ -d "./local/example_site" ]; then
echo "Cleaning up local/example_site"
rm -rfd ./local/example_site
fi
echo "Setting up local/example_site"
# create a new example site
hugo new site ./local/example_site
# copy the theme to the example site
theme_repo="https://github.com/ph-ph/chalk"
theme_dir="./local/example_site/themes/chalk"
echo "Cloning theme from ${theme_repo} to ${theme_dir}"
git clone ${theme_repo} ${theme_dir}
# create comment partial
echo "Creating comment partial in local/example_site"
mkdir -p ./local/example_site/layouts/partials/comments
cat << EOF > ./local/example_site/layouts/partials/comments/comments.html
<link href="/lib/artalk/Artalk.css" rel="stylesheet">
<script src="/lib/artalk/Artalk.js"></script>
<!-- Artalk -->
<div id="Comments"></div>
<script>
Artalk.init({
el: '#Comments',
pageKey: '{{ .Permalink }}',
pageTitle: '{{ .Title }}',
server: '{{ $.Site.Params.artalk.server }}',
site: '{{ $.Site.Params.artalk.site }}',
})
</script>
EOF
# patch ${single_template}, insert code before last </article> tag
single_template=local/example_site/themes/chalk/layouts/_default/single.html
echo "Patching ${single_template}"
sed -i '/<\/article>/i {{ partial "comments/comments.html" . }}' ./${single_template}
# update the example site config
cat << EOF > ./local/example_site/config.toml
baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
theme = "chalk"
[params.chalk]
# chalk theme parameters
about_enabled = true
scrollappear_enabled = true
theme_toggle = true
rss_enabled = true
blog_theme = 'light'
local_fonts = false
[params.social]
twitter='example'
github='example'
[params.artalk]
server='http://localhost:23366'
site='Default Site'
EOF
# copy ./public/dist/Artalk.css/js to /lib/artalk/Artalk.css/js
echo "Copying ./public/dist/Artalk.css/js to /lib/artalk/Artalk.css/js"
mkdir -p ./local/example_site/static/lib/artalk
cp ./public/dist/Artalk.css ./local/example_site/static/lib/artalk/Artalk.css
cp ./public/dist/Artalk.js ./local/example_site/static/lib/artalk/Artalk.js
# create a post in the example site
echo "Creating a post in local/example_site"
mkdir -p ./local/example_site/content/posts
cat << EOF > ./local/example_site/content/posts/my-first-post.md
---
title: "My First Post"
---
# Manibus positaeque agrestes
## Inmurmurat posset saxa
Lorem markdownum undas, sors matre fata nimiumque parte; sua carae medios. Per
ego ad turritaque pars. Privignae tenuit auget in saxo nebulis. Pende enim
Silvanusque idem favilla, tecta! Motu *modo*, Almo vertuntur sceptroque alto,
mitia.
## Fuit ardor centum materiam in inquit
Rarescit digitis, turba debuit auctor inplerant monstra, pararet. Detestatur
**saltem dubitet Aeneadae** pectora celsis doloris, est tutus et circumdat agit
poposcit *precor* et.
## Bos avidus flammas excusare corpore
Nova Rutulos, Clytien, conspicuus poterit. Ne hac cladem fatendo postquam
saevitiae Dianae torvos *fluctus*, iuvenis et. Sensit adstitit separat effectum
saevarum fecit, me date imo, adicis nubigenas **ferumque**. Res illa signis!
Videri vagi, hac mori iras exuit similis modo et tempora.
if (day_widget_saas) {
footer.rate_dhcp(4, association_data, winSpoofingMca(real,
esportsRepository, system));
}
if (unix_dma.serp(4 + trinitron, -3) ==
koffice_function.defragmentQuadMatrix(vista_kernel,
firmware_ntfs_tebibyte, -1 * bing)) {
utility *= web;
tunneling_halftone_primary(-2 + bare, -5, bmp + 5);
}
uddi += crop_error_capacity(bugCpc + boot, publishingSystemOutput(
dvdClientOptical));
if (2 == file_apple) {
cutDevelopmentData.heuristic_bridge_desktop(
softwareInfotainmentEdutainment - spam, tween,
donationwareSecondary);
} else {
serverSdramRuntime = -2;
}
## Nostrique miratur repetita suprema vocat sustulit
Dumosaque adflabat mixtaeque communicat est, Aeolus pinum. Me fecit.
domain_leak_namespace.visualMonitor(header, gps_archie(service, 4,
basic_networking_unfriend));
cisc_software_cycle.fiosHertzAndroid += plug - 5 + storage(
firewall_algorithm_troubleshooting);
eup_botnet -= 5;
computerSampleNull += uml * hard_clone_cd;
Limine habebat frigore, venenis tenebris nota. Fors erubui victa cortice
nullamque iniqui domos viroque, *inquit* ingentia, *crudelia*. Foedera qua!
*Ipsa dum perque*, mea orbi; aversus loca rutilos dona dixerat Bacchus saltus.
EOF
# run the example site
echo "Running local/example_site"
pushd ./local/example_site
hugo server
popd