Skip to content

Commit

Permalink
support Haml partials and extract the update form markup
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jun 4, 2009
1 parent 5c094fb commit 99a4a86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
8 changes: 6 additions & 2 deletions Thorfile
Expand Up @@ -2,6 +2,7 @@
require 'net/http'
require 'curl'
require 'cgi'
require 'haml'
require 'sass'
require 'stringio'

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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} ***/"
Expand Down
17 changes: 1 addition & 16 deletions endless_tweets/inline_reply.js
Expand Up @@ -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),
Expand Down
12 changes: 12 additions & 0 deletions endless_tweets/update_form.haml
@@ -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.