Changeset 1165
- Timestamp:
- 2008-09-18 17:16:57 (4 months ago)
- Files:
-
- trunk/app/models/comment.rb (modified) (2 diffs)
- trunk/app/models/node.rb (modified) (1 diff)
- trunk/app/models/version.rb (modified) (1 diff)
- trunk/lib/node_query.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/code_syntax.rb (modified) (1 diff)
- trunk/public/stylesheets/code.css (modified) (1 diff)
- trunk/test/helpers/node_query/filters.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/models/comment.rb
r1078 r1165 7 7 =end 8 8 class Comment < ActiveRecord::Base 9 zafu_readable :title, :text, :author_name, :created_at, :updated_at, :status 9 zafu_readable :title, :text, :author_name, :created_at, :updated_at, :status, :user_id, :user_zip 10 10 zafu_context :replies => ["Comment"] 11 11 attr_accessible :title, :text, :author_name, :discussion_id, :reply_to, :status … … 23 23 def author_name 24 24 self[:author_name] || (self[:user_id] ? author.fullname : nil) 25 end 26 27 def user_zip 28 user_id 25 29 end 26 30 trunk/app/models/node.rb
r1147 r1165 132 132 :section_zip, :skin, :ref_lang, :fullpath, :rootpath, :position, :publish_from, :max_status, :rgroup_id, 133 133 :wgroup_id, :pgroup_id, :basepath, :custom_base, :klass, :zip, :score, :comments_count, :l_status, :l_comment, 134 :custom_a, :custom_b, :title, :text, 134 :custom_a, :custom_b, :title, :text, :user_id, 135 135 :m_text, :m_title, :m_author 136 136 zafu_context :author => "Contact", :parent => "Node", trunk/app/models/version.rb
r1096 r1165 31 31 32 32 zafu_readable :title, :text, :summary, :comment, :created_at, :updated_at, :publish_from, :status, 33 :wgroup_id, :pgroup_id, :zip, :lang, :user_zip 33 :wgroup_id, :pgroup_id, :zip, :lang, :user_zip, :user_id 34 34 35 35 zafu_context :author => "Contact", :user => "User", :node => "Node" trunk/lib/node_query.rb
r1122 r1165 163 163 case $2 164 164 when 'visitor' 165 value = "\#{Node.connection.quote(\#{#{val_start}Node.zafu_attribute(visitor.contact, #{$3.inspect})#{val_end}})}" 165 if $3 == 'author_id' # FIXME: this is a bit hackish. If anyone has a better idea.. 166 value = "\#{visitor.id}" 167 else 168 value = "\#{Node.connection.quote(\#{#{val_start}Node.zafu_attribute(visitor.contact, #{$3.inspect})#{val_end}})}" 169 end 166 170 when 'param' 167 171 value = "\#{Node.connection.quote(#{val_start}params[:#{$3}].to_s#{val_end})}" … … 343 347 # * VCLASS: a virtual class created by the user ('posts', 'houses', ...) 344 348 # * RELATION: a relation defined by the user ('icon_for', 'news', 'calendar', ...) 345 # * CLAUSE: field = value ('log_at:year = 2005'). You can use parameters, visitor data in clause: 'log_at:year = [param:year]', 'd_assigned = [visitor:name]'. You can only use 'and' in clauses. 'or' is not supported. You canuse version and/or dynamic attributes : 'v_comment = super', 'd_priority = low'.349 # * CLAUSE: field = value ('log_at:year = 2005'). You can use parameters, visitor data in clause: 'log_at:year = [param:year]', 'd_assigned = [visitor:name]'. You can use version and/or dynamic attributes : 'v_comment = super', 'd_priority = low'. 346 350 # 347 351 # Examples: 'todos in section where d_priority = high and d_assigned = [visitor:name]' trunk/lib/parser/lib/rules/code_syntax.rb
r996 r1165 239 239 Syntax::SYNTAX['sh'] = ShTokenizer 240 240 241 241 class PseudoSqlTokenizer < Syntax::Tokenizer 242 def step 243 if @state.nil? and method = scan(/\w+/) 244 start_group :method, method 245 @state = :method 246 elsif @state == :in and context = scan(/\w+/) 247 start_group :context, context 248 @state = :context 249 elsif keyword = scan(/\bin\b/) 250 start_group :context, keyword 251 @state = :in 252 elsif keyword = scan(/\bfrom\b/) 253 start_group :sub, keyword 254 @state = nil 255 elsif keyword = scan(/\bwhere|order\b/) 256 start_group :keyword, keyword 257 elsif punct = scan(/\b>=|<=|<>|<|=|>|not\s+like|like|lt|le|eq|ne|ge|gt\b/) 258 start_group :punct, punct 259 elsif string = scan(/("|')[^'"]*\1/) 260 string =~ /("|')([^'"]*)\1/ 261 start_group :punct, $1 262 start_group :string, $2 263 start_group :punct, $1 264 else 265 start_group :normal, scan(/./m) 266 end 267 end 268 end 269 Syntax::SYNTAX['pseudo_sql'] = PseudoSqlTokenizer 270 271 trunk/public/stylesheets/code.css
r1144 r1165 51 51 .css .class { color:orange;} 52 52 53 .pseudo_sql .string { color: #361; } 54 .pseudo_sql .keyword { color: #622;} 55 .pseudo_sql .sub { color:#622; font-weight:bold;} 56 .pseudo_sql .punct {color: #622;} 57 .pseudo_sql .method {color: #944;} 58 .pseudo_sql .context {color: #07b;} 53 59 54 60 .zazen pre { trunk/test/helpers/node_query/filters.yml
r1084 r1165 91 91 src: "nodes in site group by log_at:year order by log_at:year asc, name asc" 92 92 sql: "SELECT nodes.* FROM nodes WHERE (#{@node.secure_scope('nodes')}) GROUP BY year(nodes.log_at) ORDER BY year(nodes.log_at) ASC, nodes.name ASC" 93 94 nodes_author: 95 context: 96 visitor: ant 97 src: "nodes where user_id eq \"[visitor:author_id]\" in site" 98 sql: "SELECT nodes.* FROM nodes WHERE nodes.user_id = \#{visitor.id} AND (\#{@node.secure_scope('nodes')}) ORDER BY nodes.position ASC, nodes.name ASC" 99 res: "."
