diff --git a/README.md b/README.md index 2e518bee9b..af2c00f418 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,7 @@ $subscriber = new \MailPoet\Models\Subscriber(); Acceptance and spec tests. - /mailpoet.php -Kickstart file. \ No newline at end of file +Kickstart file. + +# Stylus command +stylus -w assets/css/src/*.styl -o assets/css/ \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/assets/css/common.css b/assets/css/common.css new file mode 100644 index 0000000000..30f538e252 --- /dev/null +++ b/assets/css/common.css @@ -0,0 +1,27 @@ +.clearfix:after { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + overflow: hidden; +} +.clearfix { + display: inline-table; +} +* html .clearfix { + height: 1%; +} +.clearfix { + display: block; +} +.mailpoet_notice { + position: relative; +} +.mailpoet_notice_close { + position: absolute; + right: 0.5em; + top: 0.5em; + color: #999; + text-decoration: none; +} diff --git a/assets/css/mailpoet_notice.css b/assets/css/mailpoet_notice.css deleted file mode 100644 index 5a90c95ebc..0000000000 --- a/assets/css/mailpoet_notice.css +++ /dev/null @@ -1,10 +0,0 @@ -.mailpoet_notice { - position: relative; -} -.mailpoet_notice_close { - position: absolute; - right: 0.5em; - top: 0.5em; - color: #999; - text-decoration: none; -} \ No newline at end of file diff --git a/assets/css/public.css b/assets/css/public.css deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/assets/css/src/common.styl b/assets/css/src/common.styl index 891ae36500..7e12a5cf4e 100644 --- a/assets/css/src/common.styl +++ b/assets/css/src/common.styl @@ -17,3 +17,14 @@ display: block // colors + +// notices +.mailpoet_notice + position: relative + +.mailpoet_notice_close + position: absolute + right: 0.5em + top: 0.5em + color: #999 + text-decoration: none \ No newline at end of file diff --git a/assets/css/src/settings.styl b/assets/css/src/settings.styl deleted file mode 100644 index 5e20df957b..0000000000 --- a/assets/css/src/settings.styl +++ /dev/null @@ -1,6 +0,0 @@ -body-color = invert(#333) -body-background = invert(#ccc) - -body - color body-color - background-color: body-background \ No newline at end of file diff --git a/assets/js/src/mailpoet_modal.js b/assets/js/mailpoet_modal.js similarity index 100% rename from assets/js/src/mailpoet_modal.js rename to assets/js/mailpoet_modal.js diff --git a/assets/js/src/mailpoet_notice.js b/assets/js/mailpoet_notice.js similarity index 100% rename from assets/js/src/mailpoet_notice.js rename to assets/js/mailpoet_notice.js diff --git a/lib/config/initializer.php b/lib/config/initializer.php index b640361734..0b1982e46d 100644 --- a/lib/config/initializer.php +++ b/lib/config/initializer.php @@ -1,6 +1,7 @@ renderer->addGlobal('assets_url', $this->assets_url); + // $this->renderer->addGlobal('assets_url', $this->assets_url); + $this->renderer->addExtension(new Renderer\Assets($this->assets_url)); register_activation_hook( $this->file, @@ -50,30 +52,30 @@ class Initializer { ); // public assets - add_action( - 'wp_enqueue_scripts', - array($this, 'public_css'), - 10 - ); - add_action( - 'wp_enqueue_scripts', - array($this, 'public_js'), - 10 - ); + // add_action( + // 'wp_enqueue_scripts', + // array($this, 'public_css'), + // 10 + // ); + // add_action( + // 'wp_enqueue_scripts', + // array($this, 'public_js'), + // 10 + // ); // admin assets - add_action( - 'admin_enqueue_scripts', - array($this, 'admin_css'), - 10, - 1 - ); - add_action( - 'admin_enqueue_scripts', - array($this, 'admin_js'), - 10, - 1 - ); + // add_action( + // 'admin_enqueue_scripts', + // array($this, 'admin_css'), + // 10, + // 1 + // ); + // add_action( + // 'admin_enqueue_scripts', + // array($this, 'admin_js'), + // 10, + // 1 + // ); // localization $this->setup_textdomain(); diff --git a/lib/renderer/assets.php b/lib/renderer/assets.php new file mode 100644 index 0000000000..68a924569a --- /dev/null +++ b/lib/renderer/assets.php @@ -0,0 +1,65 @@ +assets_url = $assets_url; + } + + public function getName() { + return 'assets'; + } + + public function getGlobals() { + return array( + 'assets_url' => $this->assets_url + ); + } + + public function getFunctions() { + return array( + new \Twig_SimpleFunction( + 'stylesheet', + array($this, 'generate_stylesheet'), + array('is_safe' => array('all')) + ), + new \Twig_SimpleFunction( + 'javascript', + array($this, 'generate_javascript'), + array('is_safe' => array('all')) + ) + ); + } + + public function generate_stylesheet() { + $stylesheets = func_get_args(); + $output = array(); + + foreach($stylesheets as $stylesheet) { + $output[] = ''; + } + + return join("\n", $output); + } + + public function generate_javascript() { + $scripts = func_get_args(); + $output = array(); + + foreach($scripts as $script) { + $output[] = ''; + } + + return join("\n", $output); + } +} \ No newline at end of file diff --git a/views/layout.html b/views/layout.html index e4e596c4f6..5dbe4bd385 100644 --- a/views/layout.html +++ b/views/layout.html @@ -8,10 +8,15 @@ {% block content %}{% endblock %} - - - - - - \ No newline at end of file + +{{ stylesheet( + 'common.css', + 'mailpoet_modal.css' +)}} + + +{{ javascript( + 'mailpoet_notice.js', + 'mailpoet_modal.js' +)}} \ No newline at end of file