Skip to content

Commit

Permalink
regex thing for the first tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg committed Aug 23, 2010
1 parent 92be311 commit 87f3641
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 299 deletions.
256 changes: 0 additions & 256 deletions README

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
@@ -0,0 +1,4 @@
Comfortable Mexican Sofa (CMS)
==============================

TODO
2 changes: 0 additions & 2 deletions app/models/cms_block.rb

This file was deleted.

3 changes: 3 additions & 0 deletions app/models/cms_page.rb
@@ -1,2 +1,5 @@
class CmsPage < ActiveRecord::Base

has_many :page_contents, :dependent => :destroy

end
10 changes: 10 additions & 0 deletions app/models/cms_page_content.rb
@@ -0,0 +1,10 @@
class CmsPageContent < ActiveRecord::Base

belongs_to :cms_page

# -- Class Methods --------------------------------------------------------
def self.initialize_content_objects(content = '')
raise tag_signature.to_s
end

end
13 changes: 13 additions & 0 deletions app/models/cms_page_text_content.rb
@@ -0,0 +1,13 @@
class CmsPageTextContent < CmsPageContent

# -- Class Methods --------------------------------------------------------

# will match tags with this format:
# <cms:page:label:text />
# <cms:page:label />
def self.regex_tag_signature(label = nil)
label ||= /\w+/
/<\s*?cms:page:(#{label}):?(text)?\s*?\/?>/
end

end
13 changes: 5 additions & 8 deletions app/models/cms_snippet.rb
@@ -1,20 +1,17 @@
class CmsSnippet < ActiveRecord::Base

# -- Validations ----------------------------------------------------------
# -- Scopes ---------------------------------------------------------------
default_scope :order => 'label'

# -- Validations ----------------------------------------------------------
validates :label,
:presence => true,
:presence => true,
:uniqueness => true,
:format => { :with => /^\w[a-z0-9_-]*$/i }
:format => { :with => /^\w[a-z0-9_-]*$/i }

# -- Class Methods --------------------------------------------------------

def self.content_for(label)
(s = find_by_label(label)) ? s.content : ''
end

# -- Scopes ---------------------------------------------------------------

default_scope :order => 'label'

end

0 comments on commit 87f3641

Please sign in to comment.