Refactor the image url generation (for relative paths) to be a
function. Any background image passed to generate_backround_css() is
automatically checked, and any others can be manually checked with:
var string image_url = generate_image_url( $*image_property );
Patch by wyntarvox.
diffs (189 lines):
diff -r 2a64c36cd347 -r b4f3b76b3de7 bin/upgrading/s2layers/colorside/layout.s2
--- a/bin/upgrading/s2layers/colorside/layout.s2 Sat Oct 03 03:20:30
2009 +0000
+++ b/bin/upgrading/s2layers/colorside/layout.s2 Sat Oct 03 13:45:10
2009 +0000
@@ -6,12 +6,6 @@ layerinfo lang = "en";
set layout_authors = [ { "name" => "branchandroot", "type" => "user" } ];
set layout_type = "two-columns-right";
-
-function prop_init {
- if ( $*image_background_header_url != "" and not
$*image_background_header_url->starts_with("http") ) {
- $*image_background_header_url =
"$*STATDIR/$*image_background_header_url";
- }
-}
function Page::print()
{
diff -r 2a64c36cd347 -r b4f3b76b3de7 bin/upgrading/s2layers/core2.s2
--- a/bin/upgrading/s2layers/core2.s2 Sat Oct 03 03:20:30 2009 +0000
+++ b/bin/upgrading/s2layers/core2.s2 Sat Oct 03 13:45:10 2009 +0000
@@ -2966,6 +2966,16 @@ function FriendsPage::print_stylesheets(
}
}
+function generate_image_url ( string image_path ) : string
+"Take an image property and append static diretory path if not given absolute
path"
+{
+ if ( $image_path != "" and not $image_path->starts_with("http://") ) {
+ $image_path = "$*STATDIR/$image_path";
+ }
+
+ return $image_path;
+}
+
function generate_background_css (
string background_image,
string background_image_repeat,
@@ -2978,6 +2988,7 @@ line of CSS for inclusion in your styles
var string color = ($background_color.as_string != "") ?
$background_color.as_string : "transparent";
var string background_css = "background: $color";
+ $background_image = generate_image_url ($background_image);
if ($background_image != "") {
$background_css = $background_css + " url($background_image)
$background_image_repeat $background_image_position";
}
diff -r 2a64c36cd347 -r b4f3b76b3de7 bin/upgrading/s2layers/drifting/layout.s2
--- a/bin/upgrading/s2layers/drifting/layout.s2 Sat Oct 03 03:20:30 2009 +0000
+++ b/bin/upgrading/s2layers/drifting/layout.s2 Sat Oct 03 13:45:10 2009 +0000
@@ -215,33 +215,12 @@ set module_links_order = 3;
# Functions
################################################################################
-# Prop Init
-# Initialize the module groups and header images.
-################################################################################
-function prop_init()
-{
- if ( $*image_background_header_url != "" and not
$*image_background_header_url->starts_with("http") )
- {
- $*image_background_header_url =
"$*STATDIR/$*image_background_header_url";
- }
- if ( $*image_module_header_url != "" and not
$*image_module_header_url->starts_with("http") )
- {
- $*image_module_header_url = "$*STATDIR/$*image_module_header_url";
- }
- if ( $*image_header_left != "" and not
$*image_header_left->starts_with("http") )
- {
- $*image_header_left = "$*STATDIR/$*image_header_left";
- }
- if ( $*image_header_right != "" and not
$*image_header_right->starts_with("http") )
- {
- $*image_header_right = "$*STATDIR/$*image_header_right";
- }
-}
-
# Prints out the stylesheet for Drifting
################################################################################
function Page::print_default_stylesheet()
{
+ var string image_header_left_url = generate_image_url
($*image_header_left);
+ var string image_header_right_url = generate_image_url
($*image_header_right);
var string page_background = generate_background_css
($*image_background_page_url, $*image_background_page_repeat,
$*image_background_page_position, $*color_page_background);
var string header_background = generate_background_css
($*image_background_header_url, $*image_background_header_repeat,
$*image_background_header_position, $*color_module_title);
if ($*image_background_header_height > 0) {
@@ -359,7 +338,7 @@ function Page::print_default_stylesheet(
}
.header-left {
- background-image: url($*image_header_left);
+ background-image: url($image_header_left_url);
background-repeat: no-repeat;
height: 4.7em;
float: left;
@@ -367,7 +346,7 @@ function Page::print_default_stylesheet(
}
.header-right {
- background-image: url($*image_header_right);
+ background-image: url($image_header_right_url);
height: 4.7em;
float: right;
width: 250px;
diff -r 2a64c36cd347 -r b4f3b76b3de7
bin/upgrading/s2layers/funkycircles/layout.s2
--- a/bin/upgrading/s2layers/funkycircles/layout.s2 Sat Oct 03 03:20:30
2009 +0000
+++ b/bin/upgrading/s2layers/funkycircles/layout.s2 Sat Oct 03 13:45:10
2009 +0000
@@ -81,33 +81,6 @@ set font_module_heading_size = "1.2";
set font_module_heading_size = "1.2";
set font_module_heading_units = "em";
-function prop_init {
- if ( $*image_background_page_url != "" and not
$*image_background_page_url->starts_with("http") ) {
- $*image_background_page_url = "$*STATDIR/$*image_background_page_url";
- }
-
- if ( $*image_background_header_url != "" and not
$*image_background_header_url->starts_with("http") ) {
- $*image_background_header_url =
"$*STATDIR/$*image_background_header_url";
- }
-
- if ( $*image_entry_list_background_url != "" and not
$*image_entry_list_background_url->starts_with("http") ) {
- $*image_entry_list_background_url =
"$*STATDIR/$*image_entry_list_background_url";
- }
-
- if ( $*image_module_list != "" and not
$*image_module_list->starts_with("http") ) {
- $*image_module_list = "$*STATDIR/$*image_module_list";
- }
-
- if ( $*image_module_list_active != "" and not
$*image_module_list_active->starts_with("http") ) {
- $*image_module_list_active = "$*STATDIR/$*image_module_list_active";
- }
-
- if ( $*image_module_list_hover != "" and not
$*image_module_list_hover->starts_with("http") ) {
- $*image_module_list_hover = "$*STATDIR/$*image_module_list_hover";
- }
-
-}
-
function print_stylesheet () {
var string header_background = generate_background_css
($*image_background_header_url, $*image_background_header_repeat, "",
$*color_header_background);
@@ -118,6 +91,9 @@ function print_stylesheet () {
var string page_title_colors = generate_color_css($*color_page_title,
$*color_page_title_background, new Color);
var string page_subtitle_colors =
generate_color_css($*color_page_subtitle, $*color_page_subtitle_background, new
Color);
var string module_title_colors = generate_color_css($*color_module_title,
new Color, new Color);
+ var string image_module_list_url = generate_image_url($*image_module_list);
+ var string image_module_list_active_url =
generate_image_url($*image_module_list_active);
+ var string image_module_list_hover_url =
generate_image_url($*image_module_list_hover);
var string entry_colors = generate_color_css($*color_entry_text,
$*color_entry_background, $*color_entry_border);
var string entry_title_colors = generate_color_css($*color_entry_title,
$*color_entry_title_background, new Color);
var string entry_title_font = generate_font_css($*font_entry_title,
$*font_fallback, $*font_entry_title_size, $*font_entry_title_units);
@@ -840,13 +816,13 @@ h2#pagetitle {
***************************************************************************/
.module li {
- list-style: url($*image_module_list) disc;
+ list-style: url($image_module_list_url) disc;
margin: .5em;
}
.module-navlinks li.current {
- list-style: url($*image_module_list_active) disc;
+ list-style: url($image_module_list_active_url) disc;
}
.module-navlinks li a.current {
@@ -855,7 +831,7 @@ h2#pagetitle {
}
.module-navlinks li:hover {
- list-style: url($*image_module_list_hover) disc;
+ list-style: url($image_module_list_hover_url) disc;
}
.module-tags_multilevel ul li {
diff -r 2a64c36cd347 -r b4f3b76b3de7 bin/upgrading/s2layers/modish/layout.s2
--- a/bin/upgrading/s2layers/modish/layout.s2 Sat Oct 03 03:20:30 2009 +0000
+++ b/bin/upgrading/s2layers/modish/layout.s2 Sat Oct 03 13:45:10 2009 +0000
@@ -6,12 +6,6 @@ layerinfo lang = "en";
set layout_authors = [ { "name" => "branchandroot", "type" => "user" } ];
set layout_type = "two-columns-left";
-
-function prop_init {
- if ( $*image_background_header_url != "" and not
$*image_background_header_url->starts_with("http") ) {
- $*image_background_header_url =
"$*STATDIR/$*image_background_header_url";
- }
-}
function print_stylesheet() {
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog