Skip to content

Commit

Permalink
[enhance] bootstrap: changed the import system, not using a reference…
Browse files Browse the repository at this point in the history
… anymore, simplier
  • Loading branch information
Aqua-Ye committed Feb 24, 2012
1 parent 5f15484 commit 670d506
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 55 deletions.
41 changes: 30 additions & 11 deletions stdlib/themes/bootstrap/core/core.opa
Expand Up @@ -584,8 +584,7 @@ _ = Client_code.register_css_declaration([icon16,icon32])


Bootstrap = {{ Bootstrap = {{


version = ServerReference.create("2.0.1") : reference(string) @private

compute_version_url(v:string) = compute_version_url(v:string) =
if String.le(v, "1.2.0") then if String.le(v, "1.2.0") then
"https://raw.github.com/twitter/bootstrap/v{v}/bootstrap-{v}.min.css" "https://raw.github.com/twitter/bootstrap/v{v}/bootstrap-{v}.min.css"
Expand All @@ -594,16 +593,36 @@ Bootstrap = {{
else else
"http://twitter.github.com/bootstrap/assets/css/bootstrap.css" "http://twitter.github.com/bootstrap/assets/css/bootstrap.css"


@deprecated @private
unimport() = option : DynamicResource.config = {
Resource.unregister_external_css(compute_version_url(Reference.get(version))) sufix=some("bootstrap.min.css")
prefix=none
onaccess=none
}

@private
param = {
expiration={none}
consumption={unlimited}
visibility={shared}
}

@private
publish_css(name) = DynamicResource.publish_extend(name, param, option)

@private
files_css = @static_include_directory("stdlib/themes/bootstrap/css")

@private
uri_css = Map.map(publish_css, files_css)

url(v:string) =
Map.get("stdlib/themes/bootstrap/css/{v}/bootstrap.min.css", uri_css) ?
compute_version_url(v)


@deprecated
import(v:string) = import(v:string) =
// unregister the previous registered version Resource.register_external_css(
do unimport() url(v)
// set and register the new version to import )
do Reference.set(version, v)
Resource.register_external_css(compute_version_url(v))


}} }}
Expand Up @@ -24,9 +24,9 @@
* It also includes several sets of icons. * It also includes several sets of icons.
* *
* {2 Where should I start} * {2 Where should I start}
* If you want to use the current version (1.3.0), just import this package. * If you want to use the latest version, just import this package (stdlib.themes.bootstrap).
* Otherwise, import stdlib.themes.bootstrap.core and call: Bootstrap.import(VERSION) * Otherwise, import stdlib.themes.bootstrap.v{X_Y_Z}.
* before launching your server (note: no check is performed), or import stdlib.themes.bootstrap-VERSION. * /!\ If the version you are looking for is not embed in Opa, it will reference GitHub's URL.
* *
* {3 How to use icons} * {3 How to use icons}
* There are different sizes: * There are different sizes:
Expand All @@ -44,36 +44,4 @@


import stdlib.themes.bootstrap.core import stdlib.themes.bootstrap.core


@private do Bootstrap.import("2.0.1")
option : DynamicResource.config = {
sufix=some("bootstrap.min.css")
prefix=none
onaccess=none
}

@private
param = {
expiration={none}
consumption={unlimited}
visibility={shared}
}

@private
publish_css(name) = DynamicResource.publish_extend(name, param, option)

/* resources */
@private
files_css = @static_include_directory("stdlib/themes/bootstrap/css")

@private
uri_css = Map.map(publish_css, files_css)

@private
current_bootstrap_url =
Bootstrap.compute_version_url(Reference.get(Bootstrap.version))

@private
url(name) =
Map.get("stdlib/themes/bootstrap/css/{name}", uri_css) ? current_bootstrap_url

do Resource.register_external_css(url("{Reference.get(Bootstrap.version)}/bootstrap.min.css"))
7 changes: 3 additions & 4 deletions stdlib/themes/bootstrap/v1_1_1/style.opa
@@ -1,5 +1,5 @@
/* /*
Copyright © 2011 MLstate Copyright © 2011, 2012 MLstate
This file is part of OPA. This file is part of OPA.
Expand All @@ -20,12 +20,11 @@


/** /**
* {1 About this module} * {1 About this module}
* This module allows you to use version 1.1.1 of Twitter's bootstrap style * This module allows you to use version 1.1.1 of Twitter's Bootstrap style
* (http://twitter.github.com/bootstrap/) directly in your application. * (http://twitter.github.com/bootstrap/) directly in your application.
* It also includes several sets of icons. * It also includes several sets of icons.
*/ */


import stdlib.themes.bootstrap.core import stdlib.themes.bootstrap.core


this_bootstrap_version = "1.1.1" do Bootstrap.import("1.1.1")
do Bootstrap.import(this_bootstrap_version)
7 changes: 3 additions & 4 deletions stdlib/themes/bootstrap/v1_3_0/style.opa
@@ -1,5 +1,5 @@
/* /*
Copyright © 2011 MLstate Copyright © 2011, 2012 MLstate
This file is part of OPA. This file is part of OPA.
Expand All @@ -20,12 +20,11 @@


/** /**
* {1 About this module} * {1 About this module}
* This module allows you to use version 1.3.0 of Twitter's bootstrap style * This module allows you to use version 1.3.0 of Twitter's Bootstrap style
* (http://twitter.github.com/bootstrap/) directly in your application. * (http://twitter.github.com/bootstrap/) directly in your application.
* It also includes several sets of icons. * It also includes several sets of icons.
*/ */


import stdlib.themes.bootstrap.core import stdlib.themes.bootstrap.core


this_bootstrap_version = "1.3.0" do Bootstrap.import("1.3.0")
do Bootstrap.import(this_bootstrap_version)
30 changes: 30 additions & 0 deletions stdlib/themes/bootstrap/v1_4_0/style.opa
@@ -0,0 +1,30 @@
/*
Copyright © 2011, 2012 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*/

/*Author: Ida Swarczewskaja, MLstate */

/**
* {1 About this module}
* This module allows you to use version 1.4.0 of Twitter's Bootstrap style
* (http://twitter.github.com/bootstrap/) directly in your application.
* It also includes several sets of icons.
*/

import stdlib.themes.bootstrap.core

do Bootstrap.import("1.4.0")

0 comments on commit 670d506

Please sign in to comment.