
{"id":1921,"date":"2012-06-21T15:44:08","date_gmt":"2012-06-21T14:44:08","guid":{"rendered":"http:\/\/www.matthijskamstra.nl\/blog\/?p=1921"},"modified":"2015-02-21T23:42:46","modified_gmt":"2015-02-21T22:42:46","slug":"write-css-with-hss-and-haxe-on-osx","status":"publish","type":"post","link":"https:\/\/www.matthijskamstra.nl\/blog\/2012\/06\/21\/write-css-with-hss-and-haxe-on-osx\/","title":{"rendered":"Write CSS with HSS and Haxe on OSX"},"content":{"rendered":"<p>I&#8217;m playing around with <a href=\"http:\/\/haxe.org\/\" target=\"_blank\">Haxe<\/a> for a while now. My recent experiments are with Neko and PHP.<\/p>\n<p>It&#8217;s a little flatfile CMS\/website that lets you write <a href=\"http:\/\/daringfireball.net\/projects\/markdown\/basics\" target=\"_blank\">Markdown<\/a> (I&#8217;m using <a href=\"https:\/\/github.com\/jasononeil\/mdown\" target=\"_blank\">mdown<\/a> from Jason O&#8217;Neil) for posts.<br \/>\nFor styling (css) I&#8217;m using <a href=\"https:\/\/github.com\/twitter\/bootstrap\" target=\"_blank\">Twitter Bootstrap<\/a> and for the animations the jQuery wrapper (<a href=\"https:\/\/github.com\/andyli\/jQueryExternForHaxe\" target=\"_blank\">jQueryExternForHaxe<\/a>) from Andi Li.<br \/>\nThis all is not important for the post, I was just showing off&#8230; \ud83d\ude1b &#8230;. or showing what you can controle in one project using Haxe (jQuery, php, neko, js and now CSS)!<\/p>\n<p>Using Twitter bootstrap for styling is very quick and nice. But when you want to modify that you will need to write css.<br \/>\nNot a problem, but what if you want to do it the awesome way?<\/p>\n<h3>Meet HSS<\/h3>\n<p>From the creator of Haxe (Nicolas Cannasse) comes <a href=\"http:\/\/ncannasse.fr\/projects\/hss\" target=\"_blank\">HSS<\/a>!<\/p>\n<blockquote><p>HSS is tool that extends the CSS syntax with powerful features such as variables and nested blocks. HSS is a CSS compiler which supports valid CSS syntax, so for every error that occurs during the parsing of the HSS file, it will display and error indicating at which file and which line the error occurred.<\/p><\/blockquote>\n<p>Sounds great and it&#8217;s written by someone who knows what he is doing, so lets give that a try.<br \/>\nAnd there comes trouble&#8230;<\/p>\n<p>Remember this: I work on Mac OS X 10.6.8.<\/p>\n<p><a href=\"http:\/\/www.matthijskamstra.nl\/blog\/wp-content\/uploads\/Screen-Shot-2015-02-21-at-23.30.49-e1424558431790.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.matthijskamstra.nl\/blog\/wp-content\/uploads\/Screen-Shot-2015-02-21-at-23.30.49-1024x361.png\" alt=\"hss example code\" width=\"1000\" height=\"353\" class=\"alignnone size-large wp-image-2129\" \/><\/a><\/p>\n<h3>Five steps to get started with HSS on OSX<\/h3>\n<p><strong>#1<\/strong><br \/>\nDownload the file: <a href=\"http:\/\/ncannasse.fr\/file\/hss-1.3-osx.gz\" target=\"_blank\">HSS OSX version<\/a><br \/>\nThe normal way of downloading (just click on the link) for some reason didn&#8217;t work for me. I had to download it with right-mouseclick and &#8220;Save link as&#8230;&#8221; (Google Chrome).<\/p>\n<p><strong>#2 <\/strong><br \/>\nExtract the file: the file you downloaded is a &#8220;gzip&#8221; compression file.<br \/>\nThe normale decompression program on OSX don&#8217;t work with that (Archive Utility), my default decompression program didn&#8217;t work either (The Unarchiver).<br \/>\nStuffit expander works!<\/p>\n<div class='highlight'><strong>And this is important!<\/strong> The other programs seem to work because there is a file created but its not a &#8220;exec&#8221;. Stuffit expander creates a file name &#8220;hss&#8221; other programs create a file named &#8220;hss-1.3-osx&#8221;<\/div>\n<p>There is probably a terminal version to extract (<a href=\"http:\/\/macosx.com\/forums\/mac-os-x-system-mac-software\/34089-how-extract-gz.html\" target=\"_blank\">here<\/a>) but I stopped trying when I had the file.<\/p>\n<p><strong>#3<\/strong><br \/>\nWhere to leave the HSS executable?<br \/>\nI had a little help with that: (<a href=\"http:\/\/razaina.fr\/tutorial-Your-first-website-powered-by-haXe\" target=\"_blank\">Source<\/a>) for Linux AND OSX you can place it in the &#8220;<code>usr\/bin\/<\/code>&#8221; directory.<br \/>\nThat is a hidden folder normally so you need to change that (but I hope you already did that) (<a href=\"http:\/\/danielsaidi.wordpress.com\/2009\/09\/19\/os-x-show-all-files-in-finder\/\" target=\"_blank\">read this post about it<\/a>)<br \/>\nBTW &#8220;Users&#8221; is not the same as &#8220;usr&#8221;<br \/>\nWhen you drop the HSS executable in the bin folder you will be asked for you password <\/p>\n<p><strong>#4<\/strong><br \/>\nI&#8217;m not 100% sure, but when I think about it while I write this I don&#8217;t think that you have to do this.<br \/>\nBut just in case I&#8217;m wrong&#8230;.<br \/>\nYou need to give the file permission to execute (this is still true if you don&#8217;t copy the file in the usr\/bin folder).<br \/>\nOpen the terminal and type &#8220;<code>chmod +x <\/code>&#8221; (without the quotes and don&#8217;t forget the space after x) and drag the HSS file in the terminal.<br \/>\nPress enter and you are done.<\/p>\n<h3>Create CSS with HXML<\/h3>\n<p>Now we can start with the cool stuff. Lets create an hss file:<br \/>\n(the <a href=\"http:\/\/ncannasse.fr\/projects\/hss\" target=\"_blank\">examples<\/a> are from Nicolas Cannasse himself)<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n\/\/ Property Variables\r\nvar mycolor = #1111AA;\r\nvar myfont = &quot;Trebuchet MS&quot;, Arial, sans-serif;\r\nbody {\r\n    color : $mycolor;\r\n    font : $myfont;\r\n}\r\n\/\/ Block Variables\r\nvar nomargin = { margin : 0px; padding : 0px; }\r\npre {\r\n    $nomargin;\r\n    color : #FF0000;\r\n}\r\n\/\/ nested blocks\r\n.faq {\r\n\tcolor : #BC683C;\r\n\t.form {\r\n\t\twidth : 100px;\r\n\t\ttextarea {\r\n\t\t\twidth : 100%;\r\n\t\t\theight : 80px;\r\n\t\t}\r\n\t\t.name {\r\n\t\t\tfont-weight : bold;\r\n\t\t}\r\n\t}\r\n\tul {\r\n\t\tmargin-left : 20px;\r\n\t\tmargin-bottom : 20px;\r\n\t}\r\n}\r\n<\/pre>\n<div class='highlight'>It&#8217;s probably useful to mention that ANY CSS file is an HSS file as long it&#8217;s validates.<br \/>\nThat means that you can take a .css file and rename it to .hss!<\/div>\n<p><em>(save the file as &#8220;style.hss&#8221; without quotes in the hss folder; see the folder structure below)<\/em><\/p>\n<p><strong>Now update your .hxml file!<\/strong><br \/>\n<a href=\"http:\/\/www.matthijskamstra.nl\/blog\/index.php\/2012\/06\/21\/haxe-ide-for-osx-monodevelop-3-0\/\" target=\"_blank\">Remember I use MonoDevelop 3.0 for OSX <\/a><\/p>\n<p>Here a example of the folder structure I used for this example<\/p>\n<pre class=\"brush: plain; highlight: [7]; title: ; notranslate\" title=\"\">\r\n+ Export\r\n\t+ neko\r\n\t+ php\r\n+ Source\r\n\t+ hss\r\n\t\t- style.hss\r\n\t- Foobar.hx\r\nFoobar.hxml\r\n<\/pre>\n<p>Open your Foobar.hxml file and it should look something like this:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n-cp Source\r\n-main Foobar\r\n-neko Export\/neko\/index.n\r\n\r\n--next\r\n-cp Source\r\n-main Foobar\r\n-php Export\/php\r\n\r\n--next\r\n-cmd &quot;cd Source\/hss\/&quot;\r\n-cmd &quot;hss style.hss&quot; \r\n-cmd &quot;hss style.hss -output ..\/..\/Export\/php\/&quot; \r\n-cmd &quot;hss style.hss -output ..\/..\/Export\/neko\/&quot; \r\n<\/pre>\n<div class='highlight'>The quotes are important when on OSX (possibly also for Linux)<\/div>\n<p>Now every time you compile the source for Neko\/PHP the css will be compiled in the correct folder!<\/p>\n<h3>Brrrrr<\/h3>\n<p>Okay, okay, I know I promote <a href=\"http:\/\/www.monodevelop.com\" target=\"_blank\">MonoDevelop<\/a> for Haxe coding.<br \/>\nBut&#8230; for hss\/css I don&#8217;t think you should use it&#8230;<br \/>\nI haven&#8217;t tried it yet, but the Haxe plugin for Textmate looks good for it.<\/p>\n<p>happy haxe-ing<\/p>\n<p>Sources used:<\/p>\n<ul>\n<li><a href=\"http:\/\/ncannasse.fr\/projects\/hss\" target=\"_blank\">http:\/\/ncannasse.fr\/projects\/hss<\/a><\/li>\n<li><a href=\"http:\/\/razaina.fr\/tutorial-Your-first-website-powered-by-haXe\" target=\"_blank\">http:\/\/razaina.fr\/tutorial-Your-first-website-powered-by-haXe<\/a><\/li>\n<li><a href=\"http:\/\/haxe.org\/doc\/compiler\" target=\"_blank\">http:\/\/haxe.org\/doc\/compiler<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m playing around with Haxe for a while now. My recent experiments are with Neko and PHP. It&#8217;s a little flatfile CMS\/website that lets you write Markdown (I&#8217;m using mdown from Jason O&#8217;Neil) for posts. For styling (css) I&#8217;m using Twitter Bootstrap and for the animations the jQuery wrapper (jQueryExternForHaxe) from Andi Li. This all [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2132,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[360,2,6],"tags":[371,372,373,412,366,370,368,369,253,255],"class_list":["post-1921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haxe","category-misc","category-open-source-freeware","tag-archive-utility","tag-flatfile","tag-gzip-compression","tag-haxe","tag-ide","tag-mac-os-x","tag-monodevelop","tag-nicolas-cannasse","tag-osx","tag-textmate"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/1921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/comments?post=1921"}],"version-history":[{"count":9,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/1921\/revisions"}],"predecessor-version":[{"id":2131,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/1921\/revisions\/2131"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/media\/2132"}],"wp:attachment":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/media?parent=1921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/categories?post=1921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/tags?post=1921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}