summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcompute_scripts.awk29
-rw-r--r--html/display_panel.html15
-rw-r--r--html/options.html9
3 files changed, 35 insertions, 18 deletions
diff --git a/compute_scripts.awk b/compute_scripts.awk
index e5efc49..2d7ea72 100755
--- a/compute_scripts.awk
+++ b/compute_scripts.awk
@@ -56,6 +56,7 @@ BEGIN {
directive_args_patterns["EXPORT"] = "^(" EXPORT_AS_re "|" identifier_re ")$"
directive_args_patterns["LOADJS"] = "^[^[:space:]]+$"
+ directive_args_patterns["LOADCSS"] = "^[^[:space:]]+$"
}
function validate_path(read_path, path, line) {
@@ -125,6 +126,7 @@ function process_file(path, read_path, mode,
if (mode == "html" && path == read_path) {
clear_array(page_js_deps)
page_js_deps_count = 0
+ clear_array(page_css_deps)
}
modes[path] = mode
@@ -200,7 +202,7 @@ function process_file(path, read_path, mode,
if (directive !~ \
/^(IF|ENDIF|ELSE|ELIF|ERROR|INCLUDE|INCLUDE_VERBATIM|COPY_FILE)$/ &&
(mode != "js" || directive !~ /^(IMPORT|FROM|EXPORT)$/) &&
- (mode != "html" || directive !~ /^LOADJS$/) &&
+ (mode != "html" || directive !~ /^(LOADJS|LOADCSS)$/) &&
(mode != "manifest" || directive !~ /^(LOADJS|LOADHTML)$/)) {
printf "ERROR: Invalid # directive in %s: %s\n",
read_path, line > "/dev/stderr"
@@ -300,6 +302,10 @@ function process_file(path, read_path, mode,
if (load_js_file(path, read_path, directive_args, line) < 1)
return 1
}
+ } else if (directive == "LOADCSS") {
+ if (load_css_file(path, read_path, directive_args, line,
+ page_css_deps))
+ return 1
} else if (directive == "LOADHTML") {
if (load_html_file(path, read_path, directive_args, line))
return 1
@@ -537,7 +543,7 @@ function compute_deps(js_path, dependencies, count, dependencies_added,
}
# Here js_deps and js_deps_count are optional args, used when loading scripts
-# into an HTML page to avoid having th same script loaded twice in multiple
+# into an HTML page to avoid having the same script loaded twice in multiple
# places.
function load_js_file(root_path, read_path, loaded_path, line,
js_deps, js_deps_count,
@@ -576,6 +582,25 @@ function load_js_file(root_path, read_path, loaded_path, line,
return js_deps_count
}
+# css_deps is an array used to avoid having the same stylesheet loaded twice in
+# multiple places in a single HTML page.
+function load_css_file(root_path, read_path, loaded_path, line, css_deps) {
+ delete css_deps[""]
+
+ if (validate_path(read_path, loaded_path, line))
+ return 1
+
+ if (!(loaded_path in css_deps)) {
+ css_deps[loaded_path]
+ to_copy[loaded_path]
+ added_line = ("<link rel=\"stylesheet\" type=\"text/css\" " \
+ "href=\"/" loaded_path "\" />")
+ add_line(root_path, added_line)
+ }
+
+ return 0
+}
+
function load_html_file(root_path, read_path, loaded_path, line) {
if (validate_path(read_path, loaded_path, line))
return 1
diff --git a/html/display_panel.html b/html/display_panel.html
index 5ee20f1..b042421 100644
--- a/html/display_panel.html
+++ b/html/display_panel.html
@@ -31,17 +31,12 @@
<head>
<meta charset="utf-8"/>
<title>Haketilo - page settings</title>
-#COPY_FILE html/reset.css
- <link type="text/css" rel="stylesheet" href="reset.css" />
-#COPY_FILE html/base.css
- <link type="text/css" rel="stylesheet" href="base.css" />
-#COPY_FILE html/back_button.css
- <link type="text/css" rel="stylesheet" href="back_button.css" />
-#COPY_FILE html/table.css
- <link type="text/css" rel="stylesheet" href="table.css" />
+#LOADCSS html/reset.css
+#LOADCSS html/base.css
+#LOADCSS html/back_button.css
+#LOADCSS html/table.css
#IF MOZILLA
-#COPY_FILE html/mozilla_scrollbar_fix.css
- <link type="text/css" rel="stylesheet" href="mozilla_scrollbar_fix.css" />
+#LOADCSS html/mozilla_scrollbar_fix.css
#ENDIF
<style>
body {
diff --git a/html/options.html b/html/options.html
index 14b7d44..853ba9b 100644
--- a/html/options.html
+++ b/html/options.html
@@ -31,12 +31,9 @@
<head>
<meta charset="utf-8"/>
<title>Haketilo options</title>
-#COPY_FILE html/reset.css
- <link type="text/css" rel="stylesheet" href="reset.css" />
-#COPY_FILE html/base.css
- <link type="text/css" rel="stylesheet" href="base.css" />
-#COPY_FILE html/table.css
- <link type="text/css" rel="stylesheet" href="table.css" />
+#LOADCSS html/reset.css
+#LOADCSS html/base.css
+#LOADCSS html/table.css
<style>
body {
width: 100%;