Permalink
Browse files

Moving

  • Loading branch information...
0 parents commit 6544d41497517d030892e737457eb6fa9d57027d @fdv committed Aug 30, 2008
@@ -0,0 +1,4 @@
+Typo-textfilter-tmcode
+====================
+
+Description goes here
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the typo_textfilter_tmcode plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the typo_textfilter_tmcode plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Typo-textfilter-tmcode'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,3 @@
+# Include hook code here
+
+require 'typo_textfilter_tmcode'
@@ -0,0 +1 @@
+# Install hook code here
@@ -0,0 +1,86 @@
+class Typo
+ class Textfilter
+ class TMCode < TextFilterPlugin::MacroPre
+ plugin_display_name "TMCode"
+ plugin_description "Ensures the CSS files for TextMate syntax highlighting are included."
+
+ def self.help_text
+ %{
+You can use `<typo:tmcode>` to include blocks of HTML code output by TextMate.
+Optionally you can default the block to hidden, to be expanded with a `<typo:tmcoderef>` reference.
+
+ <typo:tmcode>
+ <!-- TextMate-generated HTML code here -->
+ </typo:tmcode>
+
+ Expand or collapse my <typo:tmcoderef id="foo">code</typo:tmcoderef>.
+ <typo:tmcode hidden="true" id="foo">
+ <!-- TextMate-generated HTML code here -->
+ </typo:tmcode>
+
+You can also provide the optional attribute `theme` which specifies which theme to use for colorizing.
+The list of available themes can be seen in the config screen, where you can also pick a theme to use
+if the `theme` attribute isn't specified.
+
+The HTML code that you enclose with this macro can be generated by selecting a block of text in TextMate
+and selecting the TextMate->Create HTML From Document command.
+}
+ end
+
+ def self.macrofilter(blog,content,attrib,params,text="")
+ isHidden = attrib['hidden'] || 'false'
+ blockID = attrib['id']
+ theme = (attrib['theme'] || config_value(params, 'default-theme')).downcase.gsub(' ', '_')
+
+ isHidden = ["yes", "true", "1", "hidden"].include?(isHidden.downcase)
+
+ set_whiteboard blog, content, isHidden, theme unless content.nil?
+
+ %{<notextile><div class="textmate-source #{theme}#{isHidden ? ' tmcode-collapsed' : ''}"#{blockID ? %{ id="tmcode_#{blockID}"} : ''}>\n#{text}\n</div></notextile>}
+ end
+
+ def self.default_config
+ {"default-theme" => {:default => "twilight",
+ :description => "Default theme for tmcode snippets",
+ :options => ["Twilight", "iPlastic", "Dawn", 'Space Cadet']}}
+ end
+
+ def self.set_whiteboard(blog, content, isHidden, theme)
+ content.whiteboard['page_header_tmcode'] = <<-HTML
+ <link href="#{blog.base_url}/stylesheets/textmate/textmate.css" media="all" rel="Stylesheet" type="text/css" />
+ HTML
+ content.whiteboard["page_header_tmcode_#{theme}"] = <<-HTML unless theme.blank?
+ <link href="#{blog.base_url}/stylesheets/textmate/#{theme}.css" media="screen" rel="Stylesheet" type="text/css" />
+ HTML
+ TMCodeRef.set_whiteboard blog, content if isHidden
+ end
+ end
+
+ class TMCodeRef < TextFilterPlugin::MacroPost
+ plugin_display_name "TMCodeRef"
+ plugin_description "Adds expand/collapse links for TMCode sections."
+
+ def self.help_text
+ %{
+Use `<typo:tmcoderef id="ref">text</typo:tmcoderef>` to cause `text` to be a hyperlink which toggles
+the collapsed state of the `<typo:tmcode>` block referenced by the `id`.
+}
+ end
+
+ def self.macrofilter(blog,content,attrib,params,text="")
+ blockID = attrib['id']
+
+ set_whiteboard blog, content
+
+ %{<a href="#" onclick="toggleCodeCollapse('tmcode_#{blockID.gsub("('|\\)", "\\\\\\1")}');return false;">#{text}</a>}
+ end
+
+ def self.set_whiteboard(blog, content)
+ content.whiteboard['page_header_codecollapse'] = <<-HTML
+ <link href="#{blog.base_url}/stylesheets/codecollapse.css" media="screen" rel="Stylesheet" type="text/css" />
+ <script src="#{blog.base_url}/javascripts/codecollapse.js" type="text/javascript" defer="defer"></script>
+ HTML
+ end
+ end
+ end
+end
@@ -0,0 +1,209 @@
+/* Stylesheet generated from TextMate theme
+ *
+ * Dawn
+ *
+ *
+ */
+
+div.textmate-source.dawn pre.textmate-source {
+ color: #080808;
+ background-color: #F5F5F5;
+}
+
+div.textmate-source.dawn pre.textmate-source .linenum {
+ width: 75px;
+ padding: 0.1em 1em 0.2em 0;
+ color: #888;
+ background-color: #eee;
+}
+div.textmate-source.dawn pre.textmate-source span {
+ padding-top: 0.2em;
+ padding-bottom: 0.1em;
+}
+div.textmate-source.dawn pre.textmate-source ::selection {
+ background-color: rgba(116, 150, 207, 0.30);
+}
+/* Comment */
+div.textmate-source.dawn pre.textmate-source .comment {
+ color: #5A525F;
+ font-style: italic;
+}
+
+/* Constant */
+div.textmate-source.dawn pre.textmate-source .constant {
+ color: #811F24;
+ font-weight: bold;
+}
+
+/* Entity */
+div.textmate-source.dawn pre.textmate-source .entity {
+ color: #BF4F24;
+}
+
+/* Keyword */
+div.textmate-source.dawn pre.textmate-source .keyword {
+ color: #794938;
+}
+
+/* Storage */
+div.textmate-source.dawn pre.textmate-source .storage {
+ color: #A71D5D;
+ font-style: italic;
+}
+
+/* String */
+div.textmate-source.dawn pre.textmate-source .string .| .punctuation_definition_string {
+ color: #0B6125;
+}
+
+/* Support */
+div.textmate-source.dawn pre.textmate-source .support {
+ color: #691C97;
+}
+
+/* Variable */
+div.textmate-source.dawn pre.textmate-source .variable {
+ color: #234A97;
+}
+
+/* Punctuation */
+div.textmate-source.dawn pre.textmate-source .punctuation {
+ color: #080808;
+}
+
+/* Punctuation.separator */
+div.textmate-source.dawn pre.textmate-source .punctuation_separator {
+ color: #794938;
+}
+
+/* Invalid – Deprecated */
+div.textmate-source.dawn pre.textmate-source .invalid_deprecated {
+ color: #B52A1D;
+ font-style: italic;
+ text-decoration: underline;
+ font-weight: bold;
+}
+
+/* Invalid – Illegal */
+div.textmate-source.dawn pre.textmate-source .invalid_illegal {
+ color: #F8F8F8;
+ font-style: italic;
+ text-decoration: underline;
+ background-color: #B52A1D;
+}
+
+/* String embedded-source */
+div.textmate-source.dawn pre.textmate-source .string .source {
+ color: #080808;
+ background-color: rgba(111, 139, 186, 0.15);
+}
+
+/* String constant */
+div.textmate-source.dawn pre.textmate-source .string .constant {
+ color: #696969;
+ font-weight: bold;
+}
+
+/* String variable */
+div.textmate-source.dawn pre.textmate-source .string .variable {
+ color: #234A97;
+}
+
+/* String.regexp */
+div.textmate-source.dawn pre.textmate-source .string_regexp {
+ color: #CF5628;
+}
+
+/* String.regexp.«special» */
+div.textmate-source.dawn pre.textmate-source .string_regexp_character-class, div.textmate-source.dawn pre.textmate-source .string_regexp .constant_character_escaped, div.textmate-source.dawn pre.textmate-source .string_regexp .source_ruby_embedded, div.textmate-source.dawn pre.textmate-source .string_regexp .string_regexp_arbitrary-repitition {
+ color: #CF5628;
+ font-style: italic;
+ font-weight: bold;
+}
+
+/* String.regexp constant.character.escape */
+div.textmate-source.dawn pre.textmate-source .string_regexp .constant_character_escape {
+ color: #811F24;
+ font-weight: bold;
+}
+
+/* Embedded Source */
+div.textmate-source.dawn pre.textmate-source .text .source {
+ background-color: rgba(111, 139, 186, 0.15);
+}
+
+/* Support.function */
+div.textmate-source.dawn pre.textmate-source .support_function {
+ color: #693A17;
+}
+
+/* Support.constant */
+div.textmate-source.dawn pre.textmate-source .support_constant {
+ color: #B4371F;
+}
+
+/* Support.variable */
+div.textmate-source.dawn pre.textmate-source .support_variable {
+ color: #234A97;
+}
+
+/* Markup.list */
+div.textmate-source.dawn pre.textmate-source .markup_list {
+ color: #693A17;
+}
+
+/* Markup.heading */
+div.textmate-source.dawn pre.textmate-source .markup_heading .| .markup_heading .entity_name {
+ color: #19356D;
+ font-weight: bold;
+}
+
+/* Markup.quote */
+div.textmate-source.dawn pre.textmate-source .markup_quote {
+ color: #0B6125;
+ font-style: italic;
+ background-color: rgba(187, 187, 187, 0.19);
+}
+
+/* Markup.italic */
+div.textmate-source.dawn pre.textmate-source .markup_italic {
+ color: #080808;
+ font-style: italic;
+}
+
+/* Markup.bold */
+div.textmate-source.dawn pre.textmate-source .markup_bold {
+ color: #080808;
+ font-weight: bold;
+}
+
+/* Markup.underline */
+div.textmate-source.dawn pre.textmate-source .markup_underline {
+ color: #080808;
+ text-decoration: underline;
+}
+
+/* Markup.link */
+div.textmate-source.dawn pre.textmate-source .markup_link {
+ color: #234A97;
+ font-style: italic;
+ text-decoration: underline;
+}
+
+/* Markup.raw */
+div.textmate-source.dawn pre.textmate-source .markup_raw {
+ color: #234A97;
+ background-color: rgba(187, 187, 187, 0.19);
+}
+
+/* Markup.deleted */
+div.textmate-source.dawn pre.textmate-source .markup_deleted {
+ color: #B52A1D;
+}
+
+/* Meta.seperator */
+div.textmate-source.dawn pre.textmate-source .meta_separator {
+ color: #19356D;
+ font-weight: bold;
+ background-color: #DCDCDC;
+}
Oops, something went wrong. Retry.

0 comments on commit 6544d41

Please sign in to comment.