Permalink
Browse files

• TODO Tags/Markers now configurable via Preferences item

• Removed global variables and used bindings for ERB



git-svn-id: http://svn.textmate.org/trunk/Bundles/TODO.tmbundle@7566 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent e30f242 commit b6fb17bb0382cbaae88e8bd795da0d2c245f067f @Soryu Soryu committed Jun 23, 2007
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>name</key>
+ <string>TODO Markers</string>
+ <key>settings</key>
+ <dict>
+ <key>shellVariables</key>
+ <array>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_MARKERS</string>
+ <key>value</key>
+ <string>FIXME, TODO, CHANGED, RADAR</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_MARKERS_TRIM</string>
+ <key>value</key>
+ <string>RADAR</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_FIXME_COLOR</string>
+ <key>value</key>
+ <string>#A00000</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_FIXME_REGEXP</string>
+ <key>value</key>
+ <string>/FIX ?ME[\s,:]+(\S.*)$/i</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_TODO_COLOR</string>
+ <key>value</key>
+ <string>#CF830D</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_TODO_REGEXP</string>
+ <key>value</key>
+ <string>/TODO[\s,:]+(\S.*)$/i</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_CHANGED_COLOR</string>
+ <key>value</key>
+ <string>#008000</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_CHANGED_REGEXP</string>
+ <key>value</key>
+ <string>/CHANGED[\s,:]+(\S.*)$/</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_RADAR_COLOR</string>
+ <key>value</key>
+ <string>#0090C8</string>
+ </dict>
+ <dict>
+ <key>name</key>
+ <string>TM_TODO_RADAR_REGEXP</string>
+ <key>value</key>
+ <string>/(.*&lt;)ra?dar:\/(?:\/problem|)\/([&amp;0-9]+)(&gt;.*)$/</string>
+ </dict>
+ </array>
+ </dict>
+ <key>uuid</key>
+ <string>E276234D-0D53-429C-B579-D975F4D98224</string>
+</dict>
+</plist>
View
@@ -1,16 +0,0 @@
-- label: FIXME
- color: "#A00000"
- regexp: "/FIX ?ME[\s,:]+(\S.*)$/i"
- trim_if_empty: false
-- label: TODO
- color: "#CF830D"
- regexp: "/TODO[\s,:]+(\S.*)$/i"
- trim_if_empty: false
-- label: CHANGED
- color: "#008000"
- regexp: "/CHANGED[\s,:]+(\S.*)$/"
- trim_if_empty: false
-- label: RADAR
- color: "#0090C8"
- regexp: "/(.*<)ra?dar:\/(?:\/problem|)\/([&0-9]+)(>.*)$/"
- trim_if_empty: true
@@ -7,7 +7,7 @@
<div id="todo_list">
<ul class="counters">
- <% $tags.each do |tag| %>
+ <% tags.each do |tag| %>
<li id="counter_tab_<%= tag[:label] %>" class="bg_<%= tag[:label] %>" <% if tag[:trim_if_empty] then %>style="display: none;"<% end %>><a onclick="goTo('jump_to_<%= tag[:label] %>'); return false;" href="#jump_to_<%= tag[:label] %>" accesskey="<%= tag[:label][0..0] %>"><%= tag[:label] %></a>: <span id="count_<%= tag[:label] %>">0</span></li>
<% end %>
<li id="total_count">counting…</li>
@@ -1,5 +1,5 @@
<style type="text/css">
-<% $tags.each do |tag| %>
+<% tags.each do |tag| %>
.bg_<%= tag[:label] %> {background-color: <%= tag[:color] %>; color: #FFF; padding: 0.5ex;}
#jump_to_<%= tag[:label] %> {color: <%= tag[:color] %>;}
.color_<%= tag[:label] %> {color: <%= tag[:color] %>}
@@ -1,9 +1,9 @@
-<tr <% if $count % 2 == 0 then %> class="alternate" <% end %>>
+<tr <% if count % 2 == 0 then %> class="alternate" <% end %>>
<td class="file">
- <a title="<%= html_escape($match[:content].strip) %>" href="<%= TextMate.file_link($match[:file], $match[:line]) %>">
- <%= "#{html_escape(File.basename($match[:file]))}" %></a> (<%= $match[:line] %>)
+ <a title="<%= html_escape(match[:content].strip) %>" href="<%= TextMate.file_link(match[:file], match[:line]) %>">
+ <%= "#{html_escape(File.basename(match[:file]))}" %></a> (<%= match[:line] %>)
</td>
<td class="comment">
- <%= $match[:match] %>
+ <%= match[:match] %>
</td>
</tr>
@@ -1,10 +1,10 @@
<script type="text/javascript" charset="utf-8">
document.getElementById("current_dir_container").style.display = "none";
var box = document.getElementById("total_count");
- box.innerHTML = "Total: <%= $total %>";
+ box.innerHTML = "Total: <%= total %>";
</script>
- <% $tags.each do |tag| %>
+ <% tags.each do |tag| %>
<% next if tag[:matches].length == 0 %>
<h3><a id="jump_to_<%= tag[:label] %>"><%= tag[:label] %></a></h3>
<table class="sortable" id="table_<%= tag[:label] %>">
@@ -1,4 +1,4 @@
<script type="text/javascript" charset="utf-8">
- document.getElementById("count_<%= $match[:type] %>").innerHTML = "<%= $count %>";
- document.getElementById("counter_tab_<%= $match[:type] %>").style.display = "block";
+ document.getElementById("count_<%= match[:type] %>").innerHTML = "<%= count %>";
+ document.getElementById("counter_tab_<%= match[:type] %>").style.display = "block";
</script>
@@ -1,3 +1,3 @@
<script type="text/javascript" charset="utf-8">
- document.getElementById("current_dir").innerHTML = "<%= File.dirname($file_name) %>";
+ document.getElementById("current_dir").innerHTML = "<%= File.dirname(file_name) %>";
</script>
View
@@ -26,27 +26,25 @@
require "yaml"
include ERB::Util
-loaded_tags = YAML.load_file("#{ENV['TM_BUNDLE_SUPPORT']}/tags.yaml")
-
-# TODO: ok, this is kind of ugly and certainly could be done inline.
-# my attempts using inject on the hashes did not work however.
-$tags = []
-loaded_tags.each { |tag|
- new_tag = {}
- tag.each do |key, value|
- if value == 'true'
- new_tag[key.to_sym] = true
- elsif value == 'false'
- new_tag[key.to_sym] = false
- elsif value =~ /^\/.*\/i?$/
- new_tag[key.to_sym] = Regexp.new(value.sub(/^\/(.*)\/i?$/, '\1'), (value =~ /i$/) ? 129 : 128)
- else
- new_tag[key.to_sym] = value
- end
- end
- $tags << new_tag
+tag_names = ENV['TM_TODO_MARKERS'].split(",")
+tag_trim = ENV['TM_TODO_MARKERS_TRIM'].split(",")
+
+trim_tags = []
+tag_trim.each { |name|
+ trim_tags << name.strip
}
+tags = []
+tag_names.each { |name|
+ name.strip!
+ regexp = ENV["TM_TODO_#{name}_REGEXP"]
+ tags << {
+ :label => name,
+ :color => (ENV["TM_TODO_#{name}_COLOR"] or '#808080'),
+ :regexp => Regexp.new(regexp.sub(/^\/(.*)\/i?$/, '\1'), (regexp =~ /i$/) ? 129 : 128),
+ :trim_if_empty => trim_tags.include?(name)
+ }
+}
ignores = ENV['TM_TODO_IGNORE']
def TextMate.file_link (file, line = 0)
@@ -55,52 +53,53 @@ def TextMate.file_link (file, line = 0)
"&amp;line=" + line.to_s
end
-$tags.each do |tag|
+tags.each do |tag|
tag[:matches] = []
tag[:rendered] = ''
end
-html_head = ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_html_header.rhtml"), 0, '<>').result
+html_head = ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_html_header.rhtml"), 0, '<>').result(binding)
puts html_head(:window_title => "TODO", :page_title => "TODO List", :sub_title => ENV['TM_PROJECT_DIRECTORY'], :html_head => html_head)
-tmpl_file = "#{ENV['TM_BUNDLE_SUPPORT']}/template_head.rhtml"
-puts ERB.new(File.open(tmpl_file), 0, '<>').result
+
+puts ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_head.rhtml"), 0, '<>').result(binding)
+
STDOUT.flush
home_dir = /^#{Regexp.escape ENV['HOME']}/
-$total = 0
+total = 0
TextMate.each_text_file do |file|
next if (ignores != nil and file =~ /#{ignores}/) or File.symlink?(file)
- $file_name = file.sub(home_dir, '~')
- puts ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_update_dir.rhtml"), 0, '<>').result
- $tags.each do |tag|
+ file_name = file.sub(home_dir, '~')
+ puts ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_update_dir.rhtml"), 0, '<>').result(binding)
+ tags.each do |tag|
File.open(file) do |io|
io.grep(tag[:regexp]) do |content|
- $match = {
+ match = {
:file => file,
:line => io.lineno,
:content => content,
:type => tag[:label]
}
if tag[:label] == "RADAR" then
url = "rdar://" + $2
- $match[:match] = html_escape($1) + "<a href=\"" + url + "\">" + html_escape(url) + "</a>" + html_escape($3)
+ match[:match] = html_escape($1) + "<a href=\"" + url + "\">" + html_escape(url) + "</a>" + html_escape($3)
else
- $match[:match] = html_escape($1)
+ match[:match] = html_escape($1)
end
- tag[:matches] << $match
- $count = tag[:matches].length
- $total += 1
- puts ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_update.rhtml"), 0, '<>').result
- tag[:rendered] += ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_item.rhtml"), 0, '<>').result
+ tag[:matches] << match
+ count = tag[:matches].length
+ total += 1
+ puts ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_update.rhtml"), 0, '<>').result(binding)
+ tag[:rendered] += ERB.new(File.open("#{ENV['TM_BUNDLE_SUPPORT']}/template_item.rhtml"), 0, '<>').result binding
STDOUT.flush
end
end if File.readable?(file)
end
end
tmpl_file = "#{ENV['TM_BUNDLE_SUPPORT']}/template_tail.rhtml"
-puts ERB.new(File.open(tmpl_file), 0, '<>').result
+puts ERB.new(File.open(tmpl_file), 0, '<>').result(binding)
html_footer()

0 comments on commit b6fb17b

Please sign in to comment.