Permalink
Browse files

support Haml partials and extract the update form markup

  • Loading branch information...
mislav committed Jun 4, 2009
1 parent 5c094fb commit 99a4a86614bd7c7fdc0b5b5a95b71967646208df
Showing with 19 additions and 18 deletions.
  1. +6 −2 Thorfile
  2. +1 −16 endless_tweets/inline_reply.js
  3. +12 −0 endless_tweets/update_form.haml
View
@@ -2,6 +2,7 @@
require 'net/http'
require 'curl'
require 'cgi'
+require 'haml'
require 'sass'
require 'stringio'
@@ -95,7 +96,10 @@ class Gm < Thor
partial = case file.extension
when 'sass'
css = Sass::Engine.new(file.read, :style => :compact).to_css
- %[addCSS(#{javascript_string css})\n]
+ %[addCSS(#{javascript_string(css)})\n]
+ when 'haml'
+ html = Haml::Engine.new(file.read).to_html
+ javascript_string(html.rstrip)
when 'js'
target ||= StringIO.new
render_js_with_partials(file, target)
@@ -133,7 +137,7 @@ class Gm < Thor
rendered_partial.gsub!(/\n([^\n])/, "\n#{indentation}\\1")
end
- target << rendered_partial
+ target.puts rendered_partial
else
if code.empty?
target.puts "/*** NOT FOUND: #{partial} ***/"
@@ -13,22 +13,7 @@ if (replyLink) {
if (replyLink) {
var replyHandler = function(e) {
var container = $E('div')
- container.innerHTML = "<form method='post' id='status_update_form' class='status-update-form' action='http://twitter.com/status/update'>\
- <fieldset class='common-form standard-form'>\
- <div class='bar'>\
- <h3><label class='doing' for='status'>What are you doing?</label></h3>\
- <span class='numeric' id='chars_left_notice'>\
- <strong class='char-counter' id='status-field-char-counter'>140</strong>\
- </span>\
- </div>\
- <div class='info'>\
- <textarea name='status' id='status' rows='2' cols='40'></textarea>\
- <div class='status-btn'>\
- <input type='submit' class='status-btn round-btn disabled' id='update-submit' value='reply' name='update'/>\
- </div>\
- </div>\
- </fieldset>\
- </form>"
+ container.innerHTML = //= update_form.haml
var username = selectString('meta[@name="page-user-screen_name"]/@content'),
replyForm = $('permalink').parentNode.appendChild(container.firstChild),
@@ -0,0 +1,12 @@
+%form#status_update_form.status-update-form{ :action => "http://twitter.com/status/update", :method => "post" }
+ %fieldset.common-form.standard-form
+ .bar
+ %h3
+ %label.doing{ :for => "status" } What are you doing?
+ %span#chars_left_notice.numeric
+ %strong#status-field-char-counter.char-counter
+ 140
+ .info
+ %textarea#status{ :name => "status", :rows => "2", :cols => "40" }
+ .status-btn
+ %input#update-submit.status-btn.round-btn.disabled{ :name => "update", :type => "submit", :value => "reply" }

0 comments on commit 99a4a86

Please sign in to comment.