From 86245ba9e4341a096727158e06290fb8075654ce Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Wed, 12 Jul 2017 12:24:04 -0400 Subject: refactor: Eliminate template duplication --- src/data/templates/add.hbs | 67 ++++------------------------------- src/data/templates/approve.hbs | 68 ++++-------------------------------- src/data/templates/base.hbs | 76 ++++++++++++++++++++++++++++++++++++++++ src/data/templates/quotes.hbs | 79 ++++-------------------------------------- src/server.rs | 4 +++ 5 files changed, 98 insertions(+), 196 deletions(-) create mode 100644 src/data/templates/base.hbs diff --git a/src/data/templates/add.hbs b/src/data/templates/add.hbs index 1f5d782..dedc0db 100644 --- a/src/data/templates/add.hbs +++ b/src/data/templates/add.hbs @@ -1,53 +1,8 @@ - - - - - - Quotes fra #linux.no på freenode - - - - -
-                     _ _  
-                    | (_)_ __  _   ___  __  _ __   ___  
-              _|_|_ | | | '_ \| | | \ \/ / | '_ \ / _ \ 
-              _|_|_ | | | | | | |_| |)  ( _| | | | (_) | 
-               | |  |_|_|_| |_|\__,_/_/\_(_)_| |_|\___/ 
-             -=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=- GAMMA -=-
-
-              Legg til new quote
-
-             -=-=-=-=-=-=-=-=-=-=-
-
-
+{{#*inline "heading"}} + Legg til quote +{{/inline}} +{{#*inline "page"}}
ditt nick:

@@ -59,16 +14,6 @@ Prøv å bruke sånn ca. samme timestamp-format (HH:MM) o.l. som eksisterende qu
<- Tilbake til quotes +{{/inline}} -
-
-

linoquotes v.3 © 2004-2017 Kjetil Ørbekk, Erlend Hamberg, Vidar Holen, John H. Anthony. -

Source code at https://git.orbekk.com/linoquotes-gamma.git. -

The quotes on this page are copyright their respective owners and submitters.

-
- - - - - - +{{~> base~}} diff --git a/src/data/templates/approve.hbs b/src/data/templates/approve.hbs index 195bb0d..70b8225 100644 --- a/src/data/templates/approve.hbs +++ b/src/data/templates/approve.hbs @@ -1,53 +1,8 @@ - - - - - - Quotes fra #linux.no på freenode - - - - -
-                     _ _  
-                    | (_)_ __  _   ___  __  _ __   ___  
-              _|_|_ | | | '_ \| | | \ \/ / | '_ \ / _ \ 
-              _|_|_ | | | | | | |_| |)  ( _| | | | (_) | 
-               | |  |_|_|_| |_|\__,_/_/\_(_)_| |_|\___/ 
-             -=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=- GAMMA -=-
-                   Quotes fra #linux.no på freenode
-                  Klikk her for å legge til en quote
-
-              Sortér etter dato | score
-
-
+{{#*inline "heading"}} + Godkjenning +{{/inline}} +{{#*inline "page"}} {{#each quotes}}
@@ -61,17 +16,6 @@ Dato: {{date}},

{{/each}} +{{/inline}} - -
-
-

linoquotes v.3 © 2004-2017 Kjetil Ørbekk, Erlend Hamberg, Vidar Holen, John H. Anthony. -

Source code at https://git.orbekk.com/linoquotes-gamma.git. -

The quotes on this page are copyright their respective owners and submitters.

-
- - - - - - +{{~> base~}} diff --git a/src/data/templates/base.hbs b/src/data/templates/base.hbs new file mode 100644 index 0000000..d548965 --- /dev/null +++ b/src/data/templates/base.hbs @@ -0,0 +1,76 @@ + + + + + + Quotes fra #linux.no på freenode + + + + + +
+                     _ _  
+                    | (_)_ __  _   ___  __  _ __   ___  
+              _|_|_ | | | '_ \| | | \ \/ / | '_ \ / _ \ 
+              _|_|_ | | | | | | |_| |)  ( _| | | | (_) | 
+               | |  |_|_|_| |_|\__,_/_/\_(_)_| |_|\___/ 
+             -=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=- GAMMA -=-
+                   Quotes fra #linux.no på freenode
+                  Klikk her for å legge til en quote
+
+{{~>heading}}
+
+
+ +{{~>page}} + +
+
+

linoquotes v.3 © 2004-2017 Kjetil Ørbekk, Erlend Hamberg, Vidar Holen, John H. Anthony. +

Source code at https://git.orbekk.com/linoquotes-gamma.git. +

The quotes on this page are copyright their respective owners and submitters.

+
+ + + + + + diff --git a/src/data/templates/quotes.hbs b/src/data/templates/quotes.hbs index 45fa711..71732ab 100644 --- a/src/data/templates/quotes.hbs +++ b/src/data/templates/quotes.hbs @@ -1,65 +1,8 @@ - - - - - - Quotes fra #linux.no på freenode - - - - - -
-                     _ _  
-                    | (_)_ __  _   ___  __  _ __   ___  
-              _|_|_ | | | '_ \| | | \ \/ / | '_ \ / _ \ 
-              _|_|_ | | | | | | |_| |)  ( _| | | | (_) | 
-               | |  |_|_|_| |_|\__,_/_/\_(_)_| |_|\___/ 
-             -=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=- GAMMA -=-
-                   Quotes fra #linux.no på freenode
-                  Klikk her for å legge til en quote
-
-              Sortér etter dato | score
-
-
+{{#*inline "heading"}} + Sortér etter dato | score +{{/inline}} +{{#*inline "page"}} {{#each quotes}}
@@ -80,16 +23,6 @@ Dato: {{date}}, Score:

{{/each}} +{{/inline}} - -
-
-

linoquotes v.3 © 2004-2017 Kjetil Ørbekk, Erlend Hamberg, Vidar Holen, John H. Anthony. -

Source code at https://git.orbekk.com/linoquotes-gamma.git. -

The quotes on this page are copyright their respective owners and submitters.

-
- - - - - +{{~> base~}} diff --git a/src/server.rs b/src/server.rs index 4c8240b..ee51ef3 100644 --- a/src/server.rs +++ b/src/server.rs @@ -32,6 +32,10 @@ fn make_renderer() -> HandlebarsEngine { let mut e = HandlebarsEngine::new(); let mut templates = BTreeMap::new(); + templates.insert( + "base".to_string(), + include_str!("data/templates/base.hbs").to_string(), + ); templates.insert( "quotes".to_string(), include_str!("data/templates/quotes.hbs").to_string(), -- cgit v1.2.3