-
Notifications
You must be signed in to change notification settings - Fork 0
/
soupault.conf
152 lines (121 loc) · 3.9 KB
/
soupault.conf
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
[settings]
verbose = true
#true means the site dir contains page bodies
#we may want to change to false which means site dir contains full pages
#but maybe not
generator_mode = true
default_template_file = "template.j2"
default_content_selector = "main"
default_content_action = "replace_content"
#false means dont put a html file in its own dir
clean_urls = true
#why TF is this needed
#page_character_encoding = "ascii"
build_dir = "."
site_dir = "text"
doctype = "<!DOCTYPE html>"
#page_file_extensions = ["html", "tsv"]
#TODO: handle title
#[widgets.title]
# widget = "preprocess_element"
# selector = "title"
# command = 'sed -e "s/{{thing_slug}}/$(basename $(basename $PAGE_FILE .tsv) .html)/" '
#[widgets.title]
# widget = "title"
# #selector = "meta[name=\"title\"][content]"
# selector = "meta[name=\"title\"]"
# extract_attribute = "content"
# default = "Alabama Transgender Rights Action Coalition"
# append = " :: ALTRAC"
[plugins.meta-extract]
lua_source = '''
source_metas = HTML.select(page, 'meta[name="' .. config["meta_name"] .. '"]')
local index = 1
while source_metas[index] do
content = HTML.get_attribute(source_metas[index], "content")
print("[EXTRACT] " .. content)
index = index + 1
end
-- now use the sucker (place into element contents)
dest_el = HTML.select_one(page, config["destination"])
new_dest_el = HTML.create_element(config["destination"], content)
HTML.insert_before(dest_el, new_dest_el)
HTML.delete(dest_el)
-- now do meta tag surgery
local index = 1
dest_meta_names = config["destination_metas"]
while dest_meta_names[index] do
print('[META] inserting into ' .. dest_meta_names[index])
-- name
dest_metas = HTML.select(page, 'meta[name="' .. dest_meta_names[index] .. '"]')
local indextwo = 1
while dest_metas[indextwo] do
HTML.set_attribute(dest_metas[indextwo], 'content', content)
print(dest_metas[indextwo])
indextwo = indextwo + 1
end
-- property
dest_metas = HTML.select(page, 'meta[property="' .. dest_meta_names[index] .. '"]')
local indextwo = 1
while dest_metas[indextwo] do
HTML.set_attribute(dest_metas[indextwo], 'content', content)
print(dest_metas[indextwo])
indextwo = indextwo + 1
end
index = index + 1
end
'''
[plugins.build-h1]
lua_source = '''
if target_file == "./index.html" then
print("lol hey")
else
title = HTML.select_one(page, 'title')
title_text = HTML.inner_html(title)
old_h1 = HTML.select_one(page, 'h1')
a = HTML.create_element('a', 'ALTRAC')
HTML.set_attribute(a, 'href', '/')
new_h1 = HTML.create_element('h1', ' · ' .. title_text)
HTML.prepend_child(new_h1, a)
HTML.insert_before(old_h1, new_h1)
HTML.delete(old_h1)
end
'''
[plugins.append-to-title]
lua_source = '''
if target_file == "./index.html" then
print("lol hey 2")
else
old_title = HTML.select_one(page, 'title')
title_text = HTML.inner_html(old_title)
new_title = HTML.create_element('title', title_text .. " :: ALTRAC")
HTML.insert_before(old_title, new_title)
HTML.delete(old_title)
end
'''
[plugins.remove-promotion]
lua_source = '''
promotion = HTML.select_one(page, 'aside.promotion')
-- HACK
if target_file == "./celebration/index.html" then
HTML.delete(promotion)
end
'''
[widgets.extract-title-from-meta]
widget = "meta-extract"
meta_name = "title"
destination = "title"
destination_metas = ["title", "og:title", "twitter:title"]
[widgets.copy-description-from-meta]
widget = "meta-extract"
meta_name = "description"
destination = "description"
destination_metas = ["description", "og:description", "twitter:description"]
[widgets.build-h1]
after = "extract-title-from-meta"
widget = "build-h1"
[widgets.append-to-title]
after = "build-h1"
widget = "append-to-title"
[widgets.remove-promotion]
widget = "remove-promotion"