Skip to content
This repository
Browse code

[enhance] bootstrap: changed the import system, not using a reference…

… anymore, simplier
  • Loading branch information...
commit 670d50641848f6bc4b166451a666409b6efb31ad 1 parent 5f15484
Frederic Ye authored February 22, 2012
41  stdlib/themes/bootstrap/core/core.opa
@@ -584,8 +584,7 @@ _ = Client_code.register_css_declaration([icon16,icon32])
584 584
 
585 585
 Bootstrap = {{
586 586
 
587  
-  version = ServerReference.create("2.0.1") : reference(string)
588  
-
  587
+  @private
589 588
   compute_version_url(v:string) =
590 589
     if String.le(v, "1.2.0") then
591 590
       "https://raw.github.com/twitter/bootstrap/v{v}/bootstrap-{v}.min.css"
@@ -594,16 +593,36 @@ Bootstrap = {{
594 593
     else
595 594
       "http://twitter.github.com/bootstrap/assets/css/bootstrap.css"
596 595
 
597  
-  @deprecated
598  
-  unimport() =
599  
-    Resource.unregister_external_css(compute_version_url(Reference.get(version)))
  596
+  @private
  597
+  option : DynamicResource.config = {
  598
+    sufix=some("bootstrap.min.css")
  599
+    prefix=none
  600
+    onaccess=none
  601
+  }
  602
+
  603
+  @private
  604
+  param = {
  605
+    expiration={none}
  606
+    consumption={unlimited}
  607
+    visibility={shared}
  608
+  }
  609
+
  610
+  @private
  611
+  publish_css(name) = DynamicResource.publish_extend(name, param, option)
  612
+
  613
+  @private
  614
+  files_css = @static_include_directory("stdlib/themes/bootstrap/css")
  615
+
  616
+  @private
  617
+  uri_css = Map.map(publish_css, files_css)
  618
+
  619
+  url(v:string) =
  620
+    Map.get("stdlib/themes/bootstrap/css/{v}/bootstrap.min.css", uri_css) ?
  621
+    compute_version_url(v)
600 622
 
601  
-  @deprecated
602 623
   import(v:string) =
603  
-    // unregister the previous registered version
604  
-    do unimport()
605  
-    // set and register the new version to import
606  
-    do Reference.set(version, v)
607  
-    Resource.register_external_css(compute_version_url(v))
  624
+    Resource.register_external_css(
  625
+      url(v)
  626
+    )
608 627
 
609 628
 }}
40  stdlib/themes/bootstrap/style.opa → stdlib/themes/bootstrap/latest.opa
@@ -24,9 +24,9 @@
24 24
  * It also includes several sets of icons.
25 25
  *
26 26
  * {2 Where should I start}
27  
- * If you want to use the current version (1.3.0), just import this package.
28  
- * Otherwise, import stdlib.themes.bootstrap.core and call: Bootstrap.import(VERSION)
29  
- * before launching your server (note: no check is performed), or import  stdlib.themes.bootstrap-VERSION.
  27
+ * If you want to use the latest version, just import this package (stdlib.themes.bootstrap).
  28
+ * Otherwise, import stdlib.themes.bootstrap.v{X_Y_Z}.
  29
+ * /!\ If the version you are looking for is not embed in Opa, it will reference GitHub's URL.
30 30
  *
31 31
  * {3 How to use icons}
32 32
  * There are different sizes:
@@ -44,36 +44,4 @@
44 44
 
45 45
 import stdlib.themes.bootstrap.core
46 46
 
47  
-@private
48  
-option : DynamicResource.config = {
49  
-  sufix=some("bootstrap.min.css")
50  
-  prefix=none
51  
-  onaccess=none
52  
-}
53  
-
54  
-@private
55  
-param = {
56  
-  expiration={none}
57  
-  consumption={unlimited}
58  
-  visibility={shared}
59  
-}
60  
-
61  
-@private
62  
-publish_css(name) = DynamicResource.publish_extend(name, param, option)
63  
-
64  
-/* resources */
65  
-@private
66  
-files_css = @static_include_directory("stdlib/themes/bootstrap/css")
67  
-
68  
-@private
69  
-uri_css = Map.map(publish_css, files_css)
70  
-
71  
-@private
72  
-current_bootstrap_url =
73  
-  Bootstrap.compute_version_url(Reference.get(Bootstrap.version))
74  
-
75  
-@private
76  
-url(name) =
77  
-  Map.get("stdlib/themes/bootstrap/css/{name}", uri_css) ? current_bootstrap_url
78  
-
79  
-do Resource.register_external_css(url("{Reference.get(Bootstrap.version)}/bootstrap.min.css"))
  47
+do Bootstrap.import("2.0.1")
7  stdlib/themes/bootstrap/v1_1_1/style.opa
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2  
-    Copyright © 2011 MLstate
  2
+    Copyright © 2011, 2012 MLstate
3 3
 
4 4
     This file is part of OPA.
5 5
 
@@ -20,12 +20,11 @@
20 20
 
21 21
 /**
22 22
  * {1 About this module}
23  
- * This module allows you to use version 1.1.1 of Twitter's bootstrap style
  23
+ * This module allows you to use version 1.1.1 of Twitter's Bootstrap style
24 24
  * (http://twitter.github.com/bootstrap/) directly in your application.
25 25
  * It also includes several sets of icons.
26 26
  */
27 27
 
28 28
 import stdlib.themes.bootstrap.core
29 29
 
30  
-this_bootstrap_version = "1.1.1"
31  
-do Bootstrap.import(this_bootstrap_version)
  30
+do Bootstrap.import("1.1.1")
7  stdlib/themes/bootstrap/v1_3_0/style.opa
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2  
-    Copyright © 2011 MLstate
  2
+    Copyright © 2011, 2012 MLstate
3 3
 
4 4
     This file is part of OPA.
5 5
 
@@ -20,12 +20,11 @@
20 20
 
21 21
 /**
22 22
  * {1 About this module}
23  
- * This module allows you to use version 1.3.0 of Twitter's bootstrap style
  23
+ * This module allows you to use version 1.3.0 of Twitter's Bootstrap style
24 24
  * (http://twitter.github.com/bootstrap/) directly in your application.
25 25
  * It also includes several sets of icons.
26 26
  */
27 27
 
28 28
 import stdlib.themes.bootstrap.core
29 29
 
30  
-this_bootstrap_version = "1.3.0"
31  
-do Bootstrap.import(this_bootstrap_version)
  30
+do Bootstrap.import("1.3.0")
30  stdlib/themes/bootstrap/v1_4_0/style.opa
... ...
@@ -0,0 +1,30 @@
  1
+/*
  2
+    Copyright © 2011, 2012 MLstate
  3
+
  4
+    This file is part of OPA.
  5
+
  6
+    OPA is free software: you can redistribute it and/or modify it under the
  7
+    terms of the GNU Affero General Public License, version 3, as published by
  8
+    the Free Software Foundation.
  9
+
  10
+    OPA is distributed in the hope that it will be useful, but WITHOUT ANY
  11
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12
+    FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
  13
+    more details.
  14
+
  15
+    You should have received a copy of the GNU Affero General Public License
  16
+    along with OPA. If not, see <http://www.gnu.org/licenses/>.
  17
+*/
  18
+
  19
+/*Author: Ida Swarczewskaja, MLstate */
  20
+
  21
+/**
  22
+ * {1 About this module}
  23
+ * This module allows you to use version 1.4.0 of Twitter's Bootstrap style
  24
+ * (http://twitter.github.com/bootstrap/) directly in your application.
  25
+ * It also includes several sets of icons.
  26
+ */
  27
+
  28
+import stdlib.themes.bootstrap.core
  29
+
  30
+do Bootstrap.import("1.4.0")

0 notes on commit 670d506

Please sign in to comment.
Something went wrong with that request. Please try again.