Skip to content

Commit

Permalink
feat: one-key site creating with artalk integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
pluveto committed Jan 17, 2023
1 parent 15e472a commit f210f15
Show file tree
Hide file tree
Showing 2 changed files with 340 additions and 0 deletions.
162 changes: 162 additions & 0 deletions internal/query/testdata/example_site_conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# This script is used by internal/query/testdata/example_site_conf.yml
# Do not modify this script unless you know what you are doing.
host: "0.0.0.0"
port: 23366
app_key: "test"
debug: false
timezone: "Asia/Shanghai"
site_default: "Default Site"
login_timeout: 259200
db:
type: "sqlite"
file: "./data/artalk.db"
table_prefix: ""
name: "artalk"
host: "localhost"
port: 3306
user: "root"
password: ""
charset: "utf8mb4"

log:
enabled: true
filename: "./data/artalk.log"
cache:
type: "builtin"
expires: 30
warm_up: false
server: ""
redis:
network: "tcp"
username: ""
password: ""
db: 0
trusted_domains: ["http://localhost:1313"]
ssl:
enabled: false
cert_path: ""
key_path: ""
admin_users:
- name: "admin"
email: "[email protected]"
password: "admin"
badge_name: "Admin"
badge_color: "#FF6C00"
moderator:
pending_default: false
api_fail_block: false
akismet_key: ""
tencent:
enabled: false
secret_id: ""
secret_key: ""
region: "ap-guangzhou"
aliyun:
enabled: false
access_key_id: ""
access_key_secret: ""
region: "cn-shanghai"
keywords:
enabled: false
pending: false
files:
file_sep: "\n"
replac_to: "x"
captcha:
enabled: true
always: false
action_limit: 3
action_reset: 60
geetest:
enabled: false
captcha_id: ""
captcha_key: ""
email:
enabled: false
send_type: "smtp"
send_name: "{{reply_nick}}"
send_addr: "[email protected]"
mail_tpl: "default"
smtp:
host: "smtp.qq.com"
port: 587
username: "[email protected]"
password: ""
ali_dm:
access_key_id: ""
access_key_secret: ""
account_name: "[email protected]"
img_upload:
enabled: true
path: "./data/artalk-img/"
max_size: 5
public_path: null
upgit:
enabled: false
exec: "./upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img"
del_local: true
admin_notify:
notify_tpl: "default"
noise_mode: false
email:
enabled: true
mail_subject: '[{{site_name}}] Post "{{page_title}}" has new a comment'
telegram:
enabled: false
api_token: ""
receivers:
- 7777777
bark:
enabled: false
server: "http://day.app/xxxxxxx/"
lark:
enabled: false
webhook_url: ""
webhook:
enabled: false
url: ""
ding_talk:
enabled: false
token: ""
secret: ""
slack:
enabled: false
oauth_token: ""
receivers:
- "CHANNEL_ID"
line:
enabled: false
channel_secret: ""
channel_access_token: ""
receivers:
- "USER_ID_1"
- "GROUP_ID_1"
frontend:
placeholder: "What do you think?"
noComment: "No comments yet."
sendBtn: "Send"
editorTravel: true
darkMode: false
emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json"
vote: true
voteDown: false
uaBadge: true
listSort: true
pvEl: "#ArtalkPV"
countEl: "#ArtalkCount"
preview: true
flatMode: "auto"
nestMax: 2
nestSort: DATE_ASC
gravatar:
mirror: "https://cravatar.cn/avatar/"
default: "mp"
pagination:
pageSize: 20
readMore: true
autoLoad: true
heightLimit:
content: 300
children: 400
reqTimeout: 15000
versionCheck: true
178 changes: 178 additions & 0 deletions scripts/setup_example_site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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>
new Artalk({
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

0 comments on commit f210f15

Please sign in to comment.