Skip to content

Commit

Permalink
Commiting changes done during the Fragment UI rewrite, not finished yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Samo Korosec committed Jan 23, 2008
1 parent e39754d commit 8a3b521
Show file tree
Hide file tree
Showing 95 changed files with 5,426 additions and 51 deletions.
43 changes: 43 additions & 0 deletions app/controllers/articles_controller.rb
Expand Up @@ -56,6 +56,49 @@ def thumbnail
render :layout => false
end

def addblock
@article = Article.find(session[:current_article])

drop_type = params[:id].split('_')[0]
drop_id = params[:id].split('_')[1]

if params[:dropfragment_id]
drop_into_fragment = params[:dropfragment_id]
elsif params[:fragment]
drop_into_fragment = @article.fragments.find_by_content(params[:fragment]).id
else
drop_into_fragment = @article.fragments.find_by_content('web').id
end

addlink = BlockLink.new unless addlink = BlockLink.find_by_fragment_id_and_position(drop_into_fragment, params['position'])
addlink.fragment_id = drop_into_fragment

case drop_type
when 'dragtextblock'
addlink.textblock_id = drop_id
when 'dragmediablock'
addlink.mediablock_id = drop_id
when 'draggallery'
addlink.gallery_id = drop_id
when 'dragarticle'
addlink.article_id = drop_id
end

if params['position']
addlink.update
addlink.position = params['position']
end
addlink.save

if params[:dropfragment_id]
redirect_to :action => 'edit', :id => @article, :fragment => Fragment.find(params['dropfragment_id']).content
elsif params[:fragment]
redirect_to :action => 'edit', :id => @article, :fragment => params['fragment']
else
redirect_to :action => 'edit', :id => @article
end
end

def show
@article = Article.find(params[:id])
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/block_links_controller.rb
Expand Up @@ -81,7 +81,6 @@ def create

def edit
@block_link = BlockLink.find(params[:id])

end

def update
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/mediablocks_controller.rb
Expand Up @@ -3,6 +3,10 @@ class MediablocksController < ApplicationController
before_filter :login_required, :except => [ :show, :show_search ]
upload_status_for :create

Mediablock.content_columns.each do |column|
in_place_edit_for :mediablock, column.name
end

def index
list
render :action => 'list'
Expand All @@ -12,7 +16,7 @@ def list
session[:current_fragment] = nil
session[:current_collection] = nil

@mediablock_pages, @mediablocks = paginate :mediablocks, :order => 'created_at DESC', :per_page => 25
@mediablocks = Mediablock.find(:all)

end

Expand Down Expand Up @@ -57,7 +61,7 @@ def create

if @mediablock.save

@mediablock.update
# @mediablock.update

addLink = BlockLink.new
addLink.linked = @mediablock
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/topics_controller.rb
Expand Up @@ -37,6 +37,17 @@ def new
def create
@topic = Topic.new(params[:topic])
if @topic.save
topic_article = new Article
if @topic.name
topic_article.name = @topic.name
end
topic_article.save!
topic_article.update

@topic.update
@topic.article_id = topic_article.id
@topic.save

respond_to do |format|
format.html { flash[:ok] = 'Topic successfully created.' }
format.js
Expand Down
2 changes: 1 addition & 1 deletion app/views/articles/_form.rhtml
Expand Up @@ -15,7 +15,7 @@

<div class="lplblock" style="width:280px">
Derzeit unter:<br/>
<%= hidden_field 'article', 'topic_id', 'value'=>@article.topic_id %>
<%# hidden_field 'article', 'topic_id', 'value'=>@article.topic_id %>
<h4>
<% if @article.topic %>
<% @article.topic.ancestors.reverse.each do |x| %>
Expand Down
33 changes: 30 additions & 3 deletions app/views/articles/edit.rhtml
@@ -1,8 +1,16 @@
<% session[:current_article] = params[:id] %>
<% session[:current_collection] = nil %>
<%
if params[:page]
session[:current_page] = params[:page]
else
session[:current_page] = 1
end
%>


<div id="lplcontainer">

<div id="dropzone">
<% thumbnail = Mediablock.find_by_id(@article.thumbnail_id) %>
<div id="thumbnaildrop">
Expand All @@ -26,9 +34,28 @@

<div id="lpltopic-select">
<%= render :partial => 'topics/selector', :locals => { :current_topic => @article.topic } %>
</div><br>
</div><br><br>

<%= render :partial => 'fragments/fragment', :collection => @fragments %>

<%= render :partial => 'fragments/ui' %>
<% if params[:fragment] == "print"
newinfragment = @article.fragments.find_by_content("print").id
else
newinfragment = @article.fragments.find_by_content("web").id
end %>
<%#link_to "Flash Vorschau", { :controller => "articles",
:action => "showswf",
:id => @article.id },
:popup => ['swf_preview', 'height=700,width=980,scrollbars=0'] -%>

<div id="lpltemplatecontainer">
<% if params[:fragment] == "print" %>
<%= render_component(:controller => "block_links", :action => "show_article", :params => {:fragment_id => @article.fragments.find_by_content("print") }) -%>
<% else %>
<%= render_component(:controller => "block_links", :action => "show_article", :params => {:fragment_id => @article.fragments.find_by_content("web") }) -%>
<% end %>
<br style="clear:both">
</div>
</div>

37 changes: 21 additions & 16 deletions app/views/block_links/_article.rhtml
@@ -1,24 +1,29 @@

<div id="block-list">
<% for link in block_links %>
<% if link.linked_type == "Textblock" %>
<div id="item_<%= link.id %>" class="sortableblock">
<%= render_partial 'textblocks/short', nil, 'textblock_id' => link.linked_id, 'link_id' => link.id %>
</div>
<% end %>

<% if link.linked_type == "Mediablock" %>
<div id="item_<%= link.id %>" class="sortableblock">
<%= render_partial 'mediablocks/short', nil, 'mediablock_id' => link.linked_id, 'link_id' => link.id %>
</div>
<% end %>
<% if @block_links %>
<% for link in block_links %>
<% if link.linked_type == "Textblock" %>
<div id="item_<%= link.id %>" class="sortableblock">
<%= render_partial 'textblocks/short', nil, 'textblock_id' => link.linked_id, 'link_id' => link.id %>
</div>
<% end %>
<% if link.linked_type == "Article" %>
<div id="item_<%= link.id %>" class="sortableblock">
<%= render_partial 'articles/short', nil, 'article_id' => link.linked_id, 'link_id' => link.id %>
</div>
<% end %>
<% if link.linked_type == "Mediablock" %>
<div id="item_<%= link.id %>" class="sortableblock">
<%= render_partial 'mediablocks/short', nil, 'mediablock_id' => link.linked_id, 'link_id' => link.id %>
</div>
<% end %>
<% if link.linked_type == "Article" %>
<div id="item_<%= link.id %>" class="sortableblock">
<%= render_partial 'articles/short', nil, 'article_id' => link.linked_id, 'link_id' => link.id %>
</div>
<% end %>
<% end %>
<% end %>
</div>
&nbsp;
Expand Down
19 changes: 3 additions & 16 deletions app/views/fragments/_form.rhtml
@@ -1,16 +1,3 @@
<%= error_messages_for 'fragment' %>

<!--[form:fragment]-->
<p><label for="fragment_position">Position</label><br/>
<%= text_field 'fragment', 'position' %></p>

<p><label for="fragment_created_at">Created at</label><br/>
<%= datetime_select 'fragment', 'created_at' %></p>

<p><label for="fragment_updated_at">Updated at</label><br/>
<%= datetime_select 'fragment', 'updated_at' %></p>

<p><label for="fragment_info">Info</label><br/>
<%= text_field 'fragment', 'info' %></p>
<!--[eoform:fragment]-->

<div class="fragmentui">
Here comes a fragment.
</div>
31 changes: 31 additions & 0 deletions app/views/fragments/_ui.rhtml
@@ -0,0 +1,31 @@
<% @article.fragments.each do |frg| %>
Fragment: <%= frg.id %><br/>

<div class="fragmentui">
<%= link_to image_tag("/images/textblock-add.png", :alt => "add textblock", :title => "add textblock"),
{ :controller => "textblocks",
:action => "new",
:rendersimple => "true",
:article_id => @article.id,
#:fragment_id => newinfragment
},
:class => "linkicon",
:popup => ['new_text', 'height=600,width=600,scrollbars=1'] -%>
<%= link_to image_tag("/images/mediablock-add.png", :alt => "add mediablock", :title => "add mediablock"),
{ :controller => "mediablocks",
:action => "new",
:rendersimple => "true",
:article_id => @article.id,
#:fragment_id => newinfragment
},
:class => "linkicon",
:popup => ['new_media', 'height=500,width=700,scrollbars=0'] -%>

<br>Here Comes A Fragment <br>

<% frg.block_links.each do |bl| %>
Block Link ID: <%= bl.id %><br/ >
<% end %>

</div>
<% end %>
3 changes: 1 addition & 2 deletions app/views/mediablocks/_short.rhtml
@@ -1,6 +1,5 @@
<% mediablock = Mediablock.find(mediablock_id) %>
<% # && session['user'].role == "admin"
if session['user'] %>
<% if current_user.admin %>
<span class="smalltext">
<%= link_to 'Bearbeiten', { :controller => "mediablocks",
:action => "edit",
Expand Down
10 changes: 7 additions & 3 deletions app/views/mediablocks/list.rhtml
Expand Up @@ -5,7 +5,6 @@
{ :action => "new",
:simple_layout => "true" },
:popup => ['new_window', 'height=400,width=600,scrollbars=1'] -%> |
<%= will_paginate @media_blocks %>
</div>
</div>

Expand All @@ -26,6 +25,7 @@
<%
#Time.now.strftime('%d-%m-%y -%R')
%>
<div class="previewcontainer">
<div class="previewblock">
<div class="iconblack">
<div class="icontainer">
Expand All @@ -36,15 +36,18 @@
</div>
<%= image_tag("/data/thumbnails/#{mediablock.filename}", :alt => mediablock.filename, :title => mediablock.title, :class => "imagepreviewmini") %>
</div>
<br style="clear:both" />
<span class="medianame"><%= mediablock.title -%></span><br>
<div class="mediadescription"><%= mediablock.description if mediablock.description -%></div>
</div>

<% end %>

<br style="clear:both" />
<br style="clear:both" />
</div>
<script type="text/javascript">

function scaleIt(v) {
var scaleDescriptions = document.getElementsByClassName('mediadescription');
var scalePhotos = document.getElementsByClassName('previewblock');
floorSize = .40;
ceilingSize = 1.0;
Expand All @@ -53,6 +56,7 @@ function scaleIt(v) {
for (i=0; i < scalePhotos.length; i++) {
scalePhotos[i].style.width = (v*200)+'px';
scalePhotos[i].style.height = (v*200)+'px';
scaleDescriptions[i].style.width = (v*200)+'px';
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/views/mediablocks/new.rhtml
Expand Up @@ -12,13 +12,12 @@
<div id="lplhelp">
Skalierung angeben mit: <code>200x300</code>,&nbsp;<code>x700</code>&nbsp;etc.
</div>
<br/>
</div>
<div id="lpltemplatecontainer">
<% form_tag ({:action => 'create' }, :multipart => true) do %>
<%= render :partial => 'form' %><br>
<%= submit_tag "Anlegen" %>
<% end_form_tag %>
<% end %>
<%= error_messages_for 'mediablock' %>
</div>
</div>
3 changes: 1 addition & 2 deletions app/views/textblocks/_short.rhtml
@@ -1,6 +1,5 @@
<% textblock = Textblock.find(textblock_id) %>
<% # && session['user'].role == "admin"
if session['user'] %>
<% if current_user.admin %>
<span class="smalltext">
<%= link_to 'Bearbeiten', { :controller => "textblocks",
:action => "edit",
Expand Down
14 changes: 14 additions & 0 deletions config/amazon_s3.yml
@@ -0,0 +1,14 @@
development:
bucket_name: appname_development
access_key_id:
secret_access_key:

test:
bucket_name: appname_test
access_key_id:
secret_access_key:

production:
bucket_name: appname
access_key_id:
secret_access_key:
4 changes: 3 additions & 1 deletion config/environment.rb
Expand Up @@ -3,6 +3,8 @@
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# ENV['RAILS_ENV'] = 'development'
ENV['RAILS_ENV'] = 'development'

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Expand Down Expand Up @@ -32,7 +34,7 @@

# Use the database for sessions instead of the file system
# (create the session table with 'rake db:sessions:create')
config.action_controller.session_store = :active_record_store
# config.action_controller.session_store = :active_record_store

# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
Expand Down

0 comments on commit 8a3b521

Please sign in to comment.