Git Product home page Git Product logo

hammer-gem's Introduction

Hammer.rb

Hammer.rb is the hammer compilation gem. Check out the "Latest" branch for the latest development version of the the compiler.

Release versions are captured in branches named after the release e.g. "5.2"

How it works

  @build = Hammer::Build.new(
    :input_directory => @input_directory,
    :output_directory => Dir.mktmpdir(),
    :cache_directory => Dir.mktmpdir()
  )
  @build.compile()

Build status

To use it:

  $ git clone [email protected]:RiotHQ/hammer-gem.git
  $ cd hammer-gem
  # install all the Gems that the compiler uses
  $ bundle install
  # vendor these gems and symlink for Ruby 2.0.0 and Ruby 1.8.7 compatibility
  $ rake bundle
  # Copy the ready-to-go gem into Hammer's Application Support directory so the Mac app uses it
  $ bundle exec rake use

Auto-update script for this branch

  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/RiotHQ/hammer-gem/latest/scripts/update.rb)"

If bundle install failed (could not find ruby/config.h)

      cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby
      sudo ln -s ../universal-darwin13/ruby/config.h ./config.h

http://stackoverflow.com/questions/26434642/yosemite-upgrade-broke-ruby-h

Advanced configuration

Since version 5.2.2 you can use autoprefixer option. Read more about Autoprefixer. In order to enable auto-prefixer for your styles you have to create a configuration file hammer.json in root of your project. This file must have next format:

{
  "sourcemaps": true,
  "autoprefixer":
  {
    "browsers": ["last 2 versions", "ie 9"]
  }
  "contentful":
  {
    "apiKey": "123456789",
    "spaces": 
    {
      "default":
      {
        "id": "987654321"
      }
    }
  }
}

There are only 2 options for now.

  1. Sourcemaps - You can enable/disable sourcemaps generation with simple true or false
  2. Autoprefixer - If you want to disable autoprefixer, you should write: "autoprefixer": false You can pass 4 different options to autoprefixer, see the autoprefixer docs for information

Troubleshooting

hammer.json is a JSON file. If you see that your configuration is having no effect, please check the format of your JSON file here.

hammer-gem's People

Contributors

elliottkember avatar isunrise avatar lumandra avatar r3trosteve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hammer-gem's Issues

Weird CSS comment issue

Sam - Pudle: One thing I've noted - couldn't work out if this is a bug or a bad line of code, but the site runs fine in 'build mode' but returns an error when optimised

it seems to be commenting a piece of the line oddly by placing the comment after the class dot. (see 2nd line)

BUILD

/* BOX */
.jbox{position:relative;}
.jbox div.jbg-wrap{position:absolute;}
.jbox div.jbg-wrap.centered,.jbox div.jbg-wrap.original{position:static;}

OPTIMISED

/* BOX */
.jbox{position:relative;}
./*jbox div.jbg-wrap{position:absolute;}*/
.jbox div.jbg-wrap.centered,.jbox div.jbg-wrap.original{position:static;}

Bug file exists at http://up.elliottkember.com/2P3S3E1Z2m2F

SCSS files in production mode

In my source HTML files, I'm using to point to the styles.scss file, found at /css/styles.scss. The smart paths feature works perfectly here until I try to build an optimized version. Then, I get this build error for my HTML files: Line 7: Error parsing .sass-cache/6be23e5a7175e1acaf14cad1a0e462710d132034/styles.scssc!

I can fix this by changing to , but doesn't that defeat the purpose of this feature?

Here is a demo document that showcases this error: http://cl.ly/QAUJ. Make sure that you have the output set to optimized to see the bug.

Fail quickly with a filesystem access check

Write to a folder in the build directory immediately on launch. That way we can fail fast if we don't have access to the directory.

Related: wrap the main executable section in a rescue block so things like this get handled.

/*@include css-gradient(#dfdfdf,#f8f8f8) */ throws an error

I'm trying to use Hammer to compile a current version of Bones, the WordPress framework, without any modifications whatsoever, and I'm running into the following error:
Line 143: bad URI(is not URI?): css-gradient(#dfdfdf,#f8f8f8);

The line in question, 143, is this:

/* @include css-gradient(#dfdfdf,#f8f8f8); */

@image tag

#2 image tag

there should be a full image tag that automatically adds the proper width and height attribute

Why single quotes and not double?

Why single quotes and not double? It's just one of those tiny details that makes me want to cry. Crazy OCD, I know. Is there any way to force double quotes or maybe add a fix for this in upcoming releases?

We should change this. It’d be way cooler to check for the first /attr=“/ style pattern in your code and mimic. I’ll make a note of it.

TODO / todo

Another small detail is how the todo feature only works with lowercase. I've been writing TODO in uppercase for ages and it's hard to learn an old dog new tricks... Possible to add a fix for this?

Sure, I think matching @todo: (or even TODO: as a secret way of doing this) would be fine if we can get the regular expression for it just right. I’ll add this to the issues list.

Should we show _style.css in the webview?

Hi Ellott,

Sorry to ask another question so soon. Why is it that files that begin with an underscore (such as _styles.css) do not show up in Hammer? Again, it could be that I'm confused, but since Hammer is designed to include them in builds, I'd thought there would be a way to open them from the app.

Thanks,
Lukas

Smart Paths issue

http://up.elliottkember.com/1a2c3z1t3u2d/hammer-folder-test.zip

The following paths to icomoon.xxx are not resolving when the .html page is nested within a folder but not giving me any errors. So, it works if .html is at folder root but not if it is nested one level deep.

@font-face {
font-family: 'icomoon';
src:url('icomoon.eot');
src:url('icomoon.eot?#iefix') format('embedded-opentype'),
url('icomoon.woff') format('woff'),
url('icomoon.ttf') format('truetype'),
url('icomoon.svg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}

I'm under the assumption that Hammer is able to resolve URLs automagically and it does so in that same page for an image but not for the font files.

Best regards,
Ryan

Error handling

Mavericks DP4 leaves us with a surprise Errno::EPERM half-way through a build, when it tries to edit a file and suddenly - operation not permitted. The reason for this is I'm not sure where to insert the error-handling part of this, with regards to the debug scripts.

If we wrap all the standard hammer executable code in a rescue block, this would help us be more resilient in the fight against the white screen of death. We might even be able to show a box with debug information. Be-have!

We also need to make interruptible.rb and hammer_time.rb overlap less.

node_modules directory not ignored properly

https://www.dropbox.com/s/ejg0lziqkvzimdn/Archive.zip

I can't send along any of the client-related stuff, but I've placed the Node / Grunt stuff on my Dropbox. If this isn't enough to go on, I completely understand. There isn't anything weird about the other content, and it's being ignored correctly. The only problem is with the parent / child node_module directories.

I changed "." to "", and everything except for node_modules was ignored, so I've changed it back.

Thanks for your help!


Just started using Hammer and am enjoying it so far. It seems to be just what I need for this project, since the backend is being developed by another company. Flat file handoff is quite handy.

One question- I can't seem to get my .hammer-ignore to ignore the node_modules. Here's my instructions list:

.*
Gruntfile.js
node_modules/*
package.json
patternlab/*

The patternlab directory is being ignored properly. Also, all file inside of node_modules are being ignored, but not the main directory or any of its children. Any suggestions?

Check order and errors for adding pages and adding links. Simon Bostock.

Step x: Create new page / save page.html to Hammer project folder with whatever header information you're using

Step y: Add link in eg. index.html to page.html using .

If you do x THEN y, it doesn't work. The Build is 'successful' but Hammer tries to link to page.html with a correctly formatted but broken URL (eg project/pages/)

If you do y THEN x, it works. The Build throws up an error message until you carry out x, but it appears to be the 'correct' way to create and link to a new page.

Issue with CSS URL paths when using url("#color") for SVGs or whatever

locationMap .datamap path {

fill: url("#circleRed") #EE4036!important;
}

I'm having a bit of trouble with Hammer; my page is using SVGs pretty
heavily, and within the Javascript of the page I'm defining several
patterns (e.g. circleGreen, circleRed).

In my CSS file, I'm referencing this pattern (or trying to):

locationMap .datamap path {

fill: url("#circleRed") #EE4036!important;
}

But Hammer is automatically re-writing the url to "../../index.htmlc".
This means that I can't get my svg fills working correctly unless I
manually edit the CSS in the build folder after it's compiled.

Is there a way around this? It's the kind of issue that's going to
stop me using Hammer in future, sadly.

Kind regards,

Let's investigate whether we can rewrite nested HTML comments

<!---
  <!-- this is not valid -->
-->

The first --> gets treated as the end of the comment. Perhaps we need to make a thing that turns the --> into ->, or something, when it's inside a comment.

Of course, Github strips HTML so pretend — is --

Edit: @lmarburger fixed the HTML by using the magic of Markdown.

Builds sometimes take 20 seconds for some users

Recompiling can be quite slow (up to 20 seconds), even though it says the files are coming from cache.
I have a feeling this may be caused by the project actually rebuilding a few times over and over from cache. I guess a timeout might be in order - don't build for X seconds after a build finishes. Probably a good idea!

Integration tests

Write a few simple, full-stack integration tests that go through hammer_time.rb and interruptable.rb.

Fix Semaphore

Emailed support and received the response below. We can do some more simple debugging to figure out if it's our problem or theirs.

If I run this file on my machine I get the same "No such file or directory" error.

However if I add this to line 48:

File.open(File.join(output_directory, "index.html"), 'w') { |file| file.write("output")

then that is taken care of. That's why I asked where is index.html created, because in your gist only the directory is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.