Skip to content

Commit

Permalink
Add support for pattern stages
Browse files Browse the repository at this point in the history
  • Loading branch information
vineacorn committed Apr 30, 2010
1 parent 8d641e4 commit 6b76481
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions app/controllers/map_controller.rb
@@ -1,4 +1,14 @@
# map_controller v0.2
# map_controller v0.3

# Changes from v0.2:
# Add support for Pattern stages
# Further WQLize and simplify db searches
# Assume all Patterns have a +stage card. This should be safe
# since creating a Pattern creates a +stage card. The
# assumption eliminates the need for a separate search to
# show Patterns that did not appear in a +related patterns card,
# and thus also eliminates the need for the "done" checklist
# used in that search.

# Changes from v0.1:
# Derive from ApplicationController instead of ActionController::Base
Expand All @@ -13,22 +23,14 @@ class MapController < ApplicationController

def show
content = []
done = {}
cards = Card.all(:include => :current_revision,
:conditions => "name LIKE '%+related patterns' AND NOT trash")
cards.each do |card|
name = card.name.sub(/\+related patterns$/,'')
Card.search(:right=>'related patterns').each do |card|
pattern = card.name.trunk_name
card.current_revision.content.scan(/\[\[([^\]]*)\]\]/) do |related|
content << name+"~->~"+related[0]
done[name] = true
done[related[0]] = true
content << pattern+"~->~"+related[0]
end
end
cards = Card.search(:type=>'Pattern')
cards.each do |card|
if (!done[card.name])
content << card.name
end
Card.search(:right=>'stage').each do |card|
content << card.name.trunk_name+"~.stage="+card.content
end
@content = content.join("\n")
end
Expand Down

0 comments on commit 6b76481

Please sign in to comment.