Permalink
Browse files

Merge branch 'wiki'

  • Loading branch information...
2 parents c133612 + db28c6f commit a38899749bf0e0832435027f01176bb170436bab @rdrake98 committed Oct 3, 2011
@@ -18,12 +18,8 @@ def show
def new
@proposal = Proposal.new
- end
-
- def moot
- @proposal = Proposal.new
- @proposal.title = URI.unescape params[:title]
- render :new
+ title = params[:title]
+ @proposal.title = URI.unescape title if title
end
def create
@@ -37,7 +37,8 @@ def wikiize(text)
names = {}
User.all.each {|user| names[user.name] = link_to(user.name, user) }
Proposal.all.each {|proposal| names[proposal.title] = link_to(proposal.title, proposal) }
- text.gsub(/\[\[(.*?)\]\]/) {|s| names[$1] || link_to($1, {:controller => "proposals", :action => "moot", :title => URI.escape($1)}) }
+ text.gsub!(/\[\[(.+?)\]\]/) {|s| names[$1] || link_to($1, {:controller => "proposals", :action => "new", :title => URI.escape($1)}, :class => "New") }
+ text.gsub(/(^|\W)(@(.+?))(\W|$)/) {|s| user = User.find_by_twitter_nickname $3; $1 + (user ? link_to($2, user) : $2) + $4 }
end
def markdown(text)
View
@@ -1,6 +1,5 @@
Vestibule::Application.routes.draw do
resources :users, :only => [:show, :edit, :update]
- get "/proposals/moot"
resources :proposals, :except => [:destroy] do
resources :suggestions, :only => [:create]
member do
@@ -123,4 +123,6 @@ header .background li {
#selections form,
#available_selections form {
float: left;
-}
+}
+
+.New {color:black;}
@@ -27,25 +27,37 @@ class ApplicationHelperTest < ActionView::TestCase
context "for a single user" do
setup do
@user = Factory(:user, :twitter_nickname => "rdrake98", :name => "Richard Drake")
+ @long = link_to("Richard Drake", "/users/rdrake98")
+ @short = link_to("@rdrake98", "/users/rdrake98")
+ end
+
+ should "not turn into link" do
+ assert_equal "[[]]", wikiize("[[]]")
+ # what about multiple lines inside [[...]]?
+ assert_equal "@other", wikiize("@other")
end
should "turn into link" do
- assert_equal link_to("Richard Drake", "/users/rdrake98"), wikiize("[[Richard Drake]]")
+ assert_equal @long, wikiize("[[Richard Drake]]")
+ assert_equal @short, wikiize("@rdrake98")
+ assert_equal "#{@long}same as #{@short}; #{@short} is but not @other.", wikiize("[[Richard Drake]]same as @rdrake98; @rdrake98 is but not @other.")
+ assert_equal "#{@long}not same as@rdrake98; #{@short} is.", wikiize("[[Richard Drake]]not same as@rdrake98; @rdrake98 is.")
+ # the following ain't perfect but we can probably live with it
+ assert_equal "#{@long}same as #{@short};@rdrake98 isn't.", wikiize("[[Richard Drake]]same as @rdrake98;@rdrake98 isn't.")
end
end
context "for a single proposal" do
setup do
@user = Factory(:proposal, :title => "My One and Only")
+ @my_only = link_to("My One and Only", "/proposals/1")
+ @her_latest = link_to("Her Latest Idea", "/proposals/new?title=Her%2520Latest%2520Idea", :class => "New")
end
should "turn into link" do
- assert_equal link_to("My One and Only", "/proposals/1"), wikiize("[[My One and Only]]")
- assert_equal link_to("Her Latest Idea", "/proposals/moot?title=Her%2520Latest%2520Idea"), wikiize("[[Her Latest Idea]]")
- assert_equal(
- "I prefer <a href=\"/proposals/moot?title=Her%2520Latest%2520Idea\">Her Latest Idea</a> to <a href=\"/proposals/1\">My One and Only</a>.",
- wikiize("I prefer [[Her Latest Idea]] to [[My One and Only]].")
- )
+ assert_equal @my_only, wikiize("[[My One and Only]]")
+ assert_equal @her_latest, wikiize("[[Her Latest Idea]]")
+ assert_equal "I prefer #{@her_latest} to #{@my_only}.", wikiize("I prefer [[Her Latest Idea]] to [[My One and Only]].")
end
end
end

0 comments on commit a388997

Please sign in to comment.