Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sebastiandeutsch/vrame
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiandeutsch committed Dec 3, 2009
2 parents 4574c3c + 66c1c62 commit 02bce9f
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 46 deletions.
8 changes: 6 additions & 2 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ def show
format.html do
@documents = @category.documents.published
@page_title = @category.title
unless @category.template.empty?
render :template => @category.template
unless @category.template.blank?
if @category.layout.blank?
render :template => @category.template
else
render :template => @category.template, :layout => @category.layout
end
end
end
format.json do
Expand Down
2 changes: 1 addition & 1 deletion app/models/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Asset < ActiveRecord::Base
:styles => lambda { |attachment|
returning(HashWithIndifferentAccess.new) do |styles|
styles.merge!(attachment.instance.vrame_styles) if attachment.instance.vrame_styles.is_a? Hash
styles.merge!(Vrame.configuration.posterframe_styles)
styles.merge!(Vrame.configuration.posterframe_styles) if Vrame.configuration.posterframe_styles.is_a? Hash
styles.merge!(Asset::DEFAULT_STYLES)
end
}
Expand Down
2 changes: 1 addition & 1 deletion app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Image < Asset
:styles => lambda { |attachment|
returning(HashWithIndifferentAccess.new) do |styles|
styles.merge!(attachment.instance.vrame_styles) if attachment.instance.vrame_styles.is_a? Hash
styles.merge!(Vrame.configuration.image_styles)
styles.merge!(Vrame.configuration.image_styles) if Vrame.configuration.image_styles.is_a? Hash
styles.merge!(Asset::DEFAULT_STYLES)
end
},
Expand Down
6 changes: 3 additions & 3 deletions app/views/vrame/categories/_documents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<% documents.each do |document| %>

<% image = nil %>
<% %w(image bild photo foto).each do |field_name| %>
<% %w(image bild photo foto thumbnail).each do |field_name| %>
<% next unless document.meta.schema.has_field?(field_name) %>
<% field = document.meta.send(field_name) %>
<% if field.file.file? %>
<% field = document.meta[field_name] %>
<% if field.is_a?(Asset) && field.file.file? && File.exist?(field.file.path) %>
<% image = image_tag(field.file.url(:vrame_backend), :alt => '') %>
<% break %>
<% end %>
Expand Down
24 changes: 14 additions & 10 deletions app/views/vrame/categories/edit_eigenvalues.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

<% form_for [:vrame, @category] do |f| %>

<fieldset>
<% @category.eigenschema.fields.each do |field| %>
<%= render :partial => 'vrame/documents/meta_field', :locals => { :parent => @category, :parent_name => 'category', :field => field } %>
<% end %>
</fieldset>
<fieldset>
<% @category.eigenschema.fields.each do |field| %>
<%= render :partial => 'vrame/shared/meta_editor/meta_field', :locals => {
:parent => @category,
:parent_name => 'category',
:field => field
} %>
<% end %>
</fieldset>

<ul>
<li class="last">
<%= f.submit 'Speichern', :class => 'submit' %> oder <%= link_to '« zurück', vrame_categories_path %>
</li>
</ul>
<ul>
<li class="last">
<%= f.submit 'Speichern', :class => 'submit' %> oder <%= link_to '« zurück', vrame_categories_path %>
</li>
</ul>

<% end %>
7 changes: 5 additions & 2 deletions app/views/vrame/documents/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
<h3>Meta-Informationen</h3>
<ul id="meta-fields">
<% category.schema.fields.each do |field| %>
<%= render :partial => 'meta_field',
:locals => { :parent => document, :parent_name => 'document', :field => field } %>
<%= render :partial => 'vrame/shared/meta_editor/meta_field', :locals => {
:parent => document,
:parent_name => 'document',
:field => field
} %>
<% end %>
</ul>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end %>
data-upload-type = "<%= type %>"
<% if defined?(uid) %> <%# TODO Dirty Hack %>
data-schema-class = "Category"
data-schema-id = "<%= parent.category.id %>"
data-schema-id = "<%= parent.is_a?(Category) ? parent.id : parent.category.id %>"
data-schema-attr = "schema"
data-schema-uid = "<%= uid %>"
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,34 @@
<% when JsonObject::Types::Bool %>

<%= hidden_field_tag field_name, 0 %>
<%= check_box_tag field_name, '1', value, :id => field_id %> <%= label field_id, "Aktivieren" %>
<label>
<%= check_box_tag field_name, '1', value %>
Aktivieren
</label>

<% when JsonObject::Types::Datetime %>

<input type="text" name="<%= field_name %>" id="<%= field_id %>" value="<%= value %>" class="datepicker" />

<% when JsonObject::Types::Select %>
<%= render :partial => 'vrame/shared/select_options', :locals => {

<%= render :partial => 'vrame/shared/meta_editor/select_options', :locals => {
:field => field,
:field_name => field_name,
:value => value
} %>

<% when JsonObject::Types::MultiSelect %>

<%= render :partial => 'vrame/shared/select_options', :locals => {
<%= render :partial => 'vrame/shared/meta_editor/select_options', :locals => {
:field => field,
:field_name => field_name,
:value => value
} %>

<% when JsonObject::Types::Asset %>

<%= render :partial => 'vrame/shared/file_upload', :locals => {
<%= render :partial => 'vrame/shared/meta_editor/file_upload', :locals => {
:field_name => field_name,
:uid => field.uid,
:asset => value,
Expand All @@ -55,22 +59,22 @@

<% when JsonObject::Types::Collection %>

<%= render :partial => 'vrame/shared/file_upload', :locals => {
<%= render :partial => 'vrame/shared/meta_editor/file_upload', :locals => {
:field_name => field_name,
:uid => field.uid,
:collection => value,
:parent => parent
} %>

<% when JsonObject::Types::Placemark %>

<%= render :partial => 'vrame/shared/placemark', :locals => {
<%= render :partial => 'placemark', :locals => {
:field_name => field_name,
:field_id => field_id,
:parent => parent,
:value => value
} %>

<% end %>

</div><!-- /.input-container -->
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<input
<% if field.is_a? JsonObject::Types::MultiSelect %>
type="checkbox"
<%= 'checked="checked"' if value.include?(option) %>
<%= 'checked="checked"' if value.is_a?(Array) && value.include?(option) %>
<% else %>
type="radio"
<%= 'checked="checked"' if value==option %>
<%= 'checked="checked"' if value == option %>
<% end %>
name="<%= field_name %>"
value="<%=h option %>">
Expand Down
18 changes: 13 additions & 5 deletions db/migrate/20091104114243_new_jsonobject_to_flexitypes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class NewJsonobjectToFlexitypes < ActiveRecord::Migration
def self.up
puts 'NewJsonobjectToFlexitypes'
Category.all.each do |category|
puts "Migrating category '#{category.title}' (ID #{category.id})"
json = JSON.parse(category.schema_json, :create_additions => false)
next if json.has_key?('json_class')
json['json_class'] = "JsonObject::Schema"
Expand Down Expand Up @@ -32,12 +34,18 @@ def self.up
end

Document.all.each do |document|
json = JSON.parse(document.meta_json, :create_additions => false)
next if json.has_key?('json_class')
json['json_class'] = "JsonObject::Store"
document.meta_json = json.to_json
document.save
puts "Migrating document '#{document.title}' (ID #{document.id})"
begin
json = JSON.parse(document.meta_json, :create_additions => false)
next if json.has_key?('json_class')
json['json_class'] = "JsonObject::Store"
document.meta_json = json.to_json
document.save
rescue
puts "Error in Document #{document.id} #{document.title}"
end
end

end

def self.down
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20091111165203_change_iso3_to_iso2_in_languages.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
class ChangeIso3ToIso2InLanguages < ActiveRecord::Migration
MAP = {'deu' => 'de', 'eng' => 'en'}
def self.up
rename_column :languages, :iso3_code, :iso2_code
Language.reset_column_information
Language.find_each {|l| l.update_attribute(:iso2_code, MAP[l.iso2_code]) }
end

def self.down
rename_column :albums, :iso2_code, :iso3_code
Language.reset_column_information
Language.find_each {|l| l.update_attribute(:iso2_code, MAP.invert[l.iso2_code]) }
end
end
11 changes: 7 additions & 4 deletions db/migrate/20091112172212_get_dimensions_from_existing_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ def self.up
puts " Posterframe: #{dim}"
end
if asset.file? && asset.file.is_image?
dim = Paperclip::Geometry.from_file(asset.file.path(:original))
asset.file_width = dim.width
asset.file_height = dim.height
puts " File: #{dim}"
filepath = asset.file.path(:original)
if File.exist?(filepath)
dim = Paperclip::Geometry.from_file(filepath)
asset.file_width = dim.width
asset.file_height = dim.height
puts " File: #{dim}"
end
end
asset.save
end
Expand Down
13 changes: 7 additions & 6 deletions public/vrame/javascripts/schema-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jQuery(function ($) {
}

/* Insert schema attribute name into input names */
function replaceFieldNames(schema_builder) {
var schema_attribute = $(schema_builder).attr('data-schema-attribute');
function replaceFieldNames (schemaBuilderId) {
var schemaBuilder = $(schemaBuilderId);
var schemaAttribute = schemaBuilder.attr('data-schema-attribute');

$(schema_builder).find('input, textarea, select').each(function () {
var field = $(this);
field.attr('name', field.attr('name').replace(/\{schema_attribute\}/, schema_attribute));
schemaBuilder.find('input, textarea, select').each(function () {
this.name = this.name.replace(/\{schema_attribute\}/, schemaAttribute);
});
}

Expand Down Expand Up @@ -197,11 +197,12 @@ jQuery(function ($) {

jQuery(function ($) {

$('#schema-builder label.required').click(toogleRequiredField);
$('#schema-builder label.required').live('click', toogleRequiredField);

function toogleRequiredField (e) {
var label = $(this),
checked = label.find('input').attr('checked') ? '1' : '0';
label.closest('td').find('input.required-field').val(checked);
}

});

0 comments on commit 02bce9f

Please sign in to comment.