Skip to content

Commit

Permalink
Created "uv" brick to improve code syntax. Fixed cached_role_ids rebu…
Browse files Browse the repository at this point in the history
…ild on rebuild_index. Using a constant for datetime value.
  • Loading branch information
gaspard committed Jun 6, 2011
1 parent a78f5e2 commit 14b7be8
Show file tree
Hide file tree
Showing 44 changed files with 1,130 additions and 884 deletions.
2 changes: 2 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Major changes
* [link] and other url related zafu tags *do not typecast to String* by default:
you need to use <r:link foo='%{baz}'/> for literal values.
* Created "uv" brick to support ultraviolet syntax highlighting.

* Minor changes
* Fixed login redirect to not leave ssh.
Expand All @@ -11,6 +12,7 @@
* Fixed [url] method to properly include port number and protocol (https).
* Improved properties and relations managment interfaces.
* Improved capistrano tasks on site rename.
* Fixed a bug where cached_role_ids would not be recalculated on rebuild rebuild.

== 1.0.0.rc3 2011-05-26

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/nodes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ def check_path
redirect_to zen_path(@node, path_params) and return false
end

if cachestamp_format?(params[:format]) && params[:cachestamp] != make_cachestamp(@node, params[:mode])
if should_cachestamp?(@node, params[:format], params[:asset]) &&
params[:cachestamp] != make_cachestamp(@node, params[:mode])
# Invalid cachestamp, redirect
redirect_to zen_path(@node, path_params) and return false
end
Expand Down
6 changes: 5 additions & 1 deletion app/models/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def export

def type_cast(value)
if ptype == 'datetime'
value.to_utc(_('datetime'), visitor.tz)
if value.blank?
nil
else
value.to_utc(_(Zena::Use::Dates::DATETIME), visitor.tz)
end
else
nil
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/data_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.transform_attributes(new_attributes, base_node = nil, parse_dates = tru
attributes.keys.each do |key|
if key == 'date'
next unless parse_dates
attributes[key] = attributes[key].to_utc(_('datetime'), visitor.tz)
attributes[key] = attributes[key].to_utc(_(Zena::Use::Dates::DATETIME), visitor.tz)
elsif key =~ /^(\w+)_id$/
if key[0..4] == 'node_'
attributes[key] = Node.translate_pseudo_id(attributes[key], :id, base_node) || attributes[key]
Expand Down
2 changes: 1 addition & 1 deletion app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def transform_attributes(new_attributes, base_node = nil, change_timezone = true
# TODO: this is a temporary hack because date in links do not support timezones/formats properly
res[key] = value.to_utc("%Y-%m-%d %H:%M:%S")
else
res[key] = value.to_utc(_('datetime'), change_timezone ? visitor.tz : nil)
res[key] = value.to_utc(_(Zena::Use::Dates::DATETIME), change_timezone ? visitor.tz : nil)
end
end
elsif key =~ /^(\w+)_id$/
Expand Down
2 changes: 1 addition & 1 deletion app/views/data_entries/_li.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tr id='data_entry<%= li[:id] %>'>
<td class='date'> <%= format_date(li.date, :format =>_('datetime')) %></td>
<td class='date'> <%= format_date(li.date, :format =>_(Zena::Use::Dates::DATETIME)) %></td>
<td class='text'> <%= li.text %></td>
<td class='value'><%= li.value %></td>
<td class='node'><%= li.node ? li.node.name : ''%></td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/discussions/_li.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<td class="box"><%= li.lang %></td>
<td class="status"><%= _(li.inside? ? 'inside' : 'outside') %> / <%= _(li.open? ? 'open' : 'closed') %></td>
<td class="comment"><%= li.comments_count(:with_prop=>true).to_s + ' ' + _('comment(s)') %></td>
<td class="date"><%= tformat_date(li.updated_at, 'datetime') %></td>
<td class="date"><%= tformat_date(li.updated_at, Zena::Use::Dates::DATETIME) %></td>
<td class="actions"><%= discussion_actions(li) %></td>
</tr>
12 changes: 8 additions & 4 deletions app/views/relations/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
<td class="dark"><%= select('relation', 'target_kpath', Node.kpaths_for_form ) %></td>
</tr>
<tr><td class="label" ><%= _('type') %></td>
<td class="light" ><%= radio_button("relation", "target_unique", true , :checked => @relation.target_unique?) %> <%= _('has_one') %>
<%= radio_button("relation", "target_unique", false, :checked => !@relation.target_unique?) %> <%= _('has_many') %></td>
<td class="dark" ><%= radio_button("relation", "source_unique", true , :checked => @relation.source_unique?) %> <%= _('has_one') %>
<%= radio_button("relation", "source_unique", false, :checked => !@relation.source_unique?) %> <%= _('has_many') %></td>
<td class="light" >
<%= radio_button("relation", "target_unique", true , :checked => @relation.target_unique?) %> <%= _('has_one') %><br/>
<%= radio_button("relation", "target_unique", false, :checked => !@relation.target_unique?) %> <%= _('has_many') %>
</td>
<td class="dark" >
<%= radio_button("relation", "source_unique", true , :checked => @relation.source_unique?) %> <%= _('has_one') %><br/>
<%= radio_button("relation", "source_unique", false, :checked => !@relation.source_unique?) %> <%= _('has_many') %>
</td>
</tr>
<tr><td class="label" ><%= _('role') %></td>
<td class="light" ><%= text_field('relation', 'target_role', :size=>18 ) %></td>
Expand Down
26 changes: 26 additions & 0 deletions bricks/uv/lib/bricks/uv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'uv'

module Bricks
module Uv
module SyntaxMethods
SYNTAXES = Hash[*::Uv.syntaxes.map{|s| [s,true]}.flatten]

def to_html(opts = {})
theme = opts[:theme] || 'idle'
line_numbers = (opts[:line_numbers] == 'true') && !opts[:inline]
code_class = "#{theme}_code"
puts SYNTAXES.inspect
if SYNTAXES[@code_lang]
res = ::Uv.parse(@text, 'xhtml', @code_lang, line_numbers, theme)
if opts[:inline]
res.gsub(/\A<pre class=.#{theme}.>/,"<code class='#{code_class}'>").gsub(%r{</pre>\Z}, '</code>')
else
res.gsub(/\A<pre class=.#{theme}.>/,"<pre class='#{code_class}'>").gsub(%r{</pre>\Z}, '</pre>')
end
else
basic_to_html(opts[:inline], code_class)
end
end
end # SyntaxMethods
end # Uv
end # Bricks
1 change: 1 addition & 0 deletions bricks/uv/zena/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Zena::CodeSyntax.send(:include, Bricks::Uv::SyntaxMethods)
9 changes: 9 additions & 0 deletions config/bricks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ test:
captcha: ON
sphinx: OFF
worker: OFF
uv: OFF

development:
asset_port: 7999
mongrel: ON
passenger: OFF
uv:
switch: ON
activate_if:
gem: 'uv'
pdf:
switch: ON
engine: prince
Expand Down Expand Up @@ -38,6 +43,10 @@ production:
asset_port: 7999
mongrel: ON
passenger: OFF
uv:
switch: ON
activate_if:
gem: 'uv'
pdf:
switch: ON
engine: prince
Expand Down
3 changes: 2 additions & 1 deletion lib/gettext_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def CustomGettext

N_('file_tab') # document form tab name
N_('template_tab') # document form tab name
N_('text_doc_tab') # document form tab name
N_('text_document_tab') # document form tab name
N_('custom_tab') # custom form tab name

N_('btn_add_doc') # used by zafu layout template
Expand Down Expand Up @@ -114,6 +114,7 @@ def CustomGettext
N_('Saturday')
N_('Sunday')

N_('datetime') # Same as %Y-%m-%d %H:%M
N_('news_date') # calendar day (event list view)

N_('Mon')
Expand Down
4 changes: 2 additions & 2 deletions lib/zena/acts/enrollable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def assigned_roles
# end

# Prepare roles to add/remove to object.
def prepare_roles
return unless prop.changed?
def prepare_roles(force = false)
return unless prop.changed? || force

keys = []
properties.each do |k, v|
Expand Down

0 comments on commit 14b7be8

Please sign in to comment.