myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2230] trunk: Added licenses table to provide gre


From: noreply
Subject: [myexperiment-hackers] [2230] trunk: Added licenses table to provide greater support for license selection
Date: Tue, 16 Jun 2009 09:02:22 -0400 (EDT)

Revision
2230
Author
drn05r
Date
2009-06-16 09:02:22 -0400 (Tue, 16 Jun 2009)

Log Message

Added licenses table to provide greater support for license selection

Modified Paths

Added Paths

Diff

Added: trunk/app/controllers/license_attributes_controller.rb (0 => 2230)


--- trunk/app/controllers/license_attributes_controller.rb	                        (rev 0)
+++ trunk/app/controllers/license_attributes_controller.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,25 @@
+class LicenseAttributesController < ApplicationController
+  before_filter :login_required
+  before_filter :find_license_attribute, : [:index]
+  
+  def destroy
+    @license_attribute = LicenseAttribute.find(params[:id])
+    @license_attribute.destroy
+
+    respond_to do |format|
+      format.html { redirect_to license_url(@license_attribute.license) }
+    end
+  end
+
+  
+  protected
+  
+  def find_license_attribute
+    begin
+      @license_attribute = LicenseAttribute.find(params[:id])
+    rescue ActiveRecord::RecordNotFound
+      error("License Attribute not found", "is invalid")
+    end
+  end
+  
+end

Added: trunk/app/controllers/licenses_controller.rb (0 => 2230)


--- trunk/app/controllers/licenses_controller.rb	                        (rev 0)
+++ trunk/app/controllers/licenses_controller.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,90 @@
+class LicensesController < ApplicationController
+  before_filter :check_admin, :except => [:show, :index]
+  
+  before_filter :find_licenses, : [:index]
+  
+  def index
+    respond_to do |format|
+      format.html # index.rhtml
+    end
+  end
+
+  def show
+    @license = License.find(params[:id])
+  end
+
+  def new
+    @license = License.new
+  end
+
+  def create
+    params[:license][:user_id] = current_user.id
+    @license = License.new(params[:license])
+    if @license.save
+      params[:license_attributes].each do |attrib,aval|
+        @license_attribute = LicenseAttribute.new(:license => @license, :license_option_id => attrib)
+        @license_attribute.save
+      end
+      flash[:notice] = 'License was successfully created.'
+      redirect_to :action ="" 'index'
+    else
+      render :action ="" 'new'
+    end
+  end
+
+  def edit
+    @license = License.find(params[:id])
+  end
+
+  def update
+    @license = License.find(params[:id])
+    @license_attributes = @license.license_attributes
+    for @attrib in @license_attributes do
+      @attrib.destroy
+    end
+    params[:license_attributes].each do |attrib,aval|
+      @license_attribute = LicenseAttribute.new(:license => @license, :license_option_id => attrib)
+      @license_attribute.save
+    end
+    if @license.update_attributes(params[:license])
+      flash[:notice] = 'License was successfully updated.'
+      redirect_to :action ="" 'show', :id => @license
+    else
+      render :action ="" 'edit'
+    end
+  end
+
+  def destroy
+    if (Workflow.find_all_by_license_id(params[:id]).empty? and Blob.find_all_by_license_id(params[:id]).empty? ) 
+     # License.find(params[:id]).destroy
+      flash[:notice] = 'License was successfully deleted.'
+    else
+      flash[:error] = 'License could not be deleted because it is in use.'
+    end
+    redirect_to :action ="" 'index'
+  end
+  
+  def update_license_form
+    license = License.find(params[:license_id])   
+    render(:partial => "licenses/view", :locals => {:license => license})
+  end
+  
+  def update_license_info
+      license = License.find(params[:license_id])
+      render :partial => "licenses/view", :locals => { :license => license }
+  end
+  
+protected
+
+  def check_admin
+    unless admin?
+      flash[:error] = 'Only administrators have access to create, update and delete licenses.'
+      redirect_to :action ="" 'index'
+    end
+  end
+  
+  def find_licenses
+    @licenses = License.find(:all, :order => "title")
+  end
+  
+end

Modified: trunk/app/controllers/workflows_controller.rb (2229 => 2230)


--- trunk/app/controllers/workflows_controller.rb	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/controllers/workflows_controller.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -253,7 +253,7 @@
     @workflow = Workflow.new
     @workflow.contributor = current_user
     @workflow.last_edited_by = current_user.id
-    @workflow.license = params[:workflow][:license]
+    @workflow.license_id = params[:workflow][:license_id]
     @workflow.content_blob = ContentBlob.new(:data ="" file.read)
     @workflow.file_ext = file.original_filename.split(".").last.downcase
     
@@ -430,7 +430,7 @@
     # remove owner only columns
     unless @workflow.contribution.owner?(current_user)
       if params[:workflow]
-        [:unique_name, :license].each do |column_name|
+        [:unique_name, :license_id].each do |column_name|
           params[:workflow].delete(column_name)
         end
       end

Modified: trunk/app/helpers/application_helper.rb (2229 => 2230)


--- trunk/app/helpers/application_helper.rb	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/helpers/application_helper.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -766,6 +766,8 @@
       return "famfamfam_silk/computer_go.png"
     when "register_application"
       return "famfamfam_silk/application_edit.png"
+    when "license"
+      return "famfamfam_silk/text_signature.png"
     else
       return Conf.label_icons[method.to_s] if Conf.label_icons[method.to_s]
     end
@@ -851,14 +853,12 @@
     }
   end
   
-  def license_link(license_type)
-    case license_type.downcase
-    when "by-nd"
-      return '<a rel="Copyright" href="" target="_blank">Creative Commons Attribution-NoDerivs 3.0 License</a>'
-    when "by"
-      return '<a rel="Copyright" href="" target="_blank">Creative Commons Attribution 3.0 License</a>'
-    when "by-sa"
-      return '<a rel="Copyright" href="" target="_blank">Creative Commons Attribution-Share Alike 3.0 License</a>'
+  def license_icon_link(license)
+    case license.unique_name
+    when "by-nd", "by-sa", "by", "by-nc-nd", "by-nc", "by-nc-sa", "GPL", "LGPL"
+      return "<a rel=\"Copyright\" href="" title=\"#{license.title}\"><img src="" /></a>"
+    else
+      return "<a rel=\"Copyright\" href=""
     end
   end
   

Added: trunk/app/helpers/license_attributes_helper.rb (0 => 2230)


--- trunk/app/helpers/license_attributes_helper.rb	                        (rev 0)
+++ trunk/app/helpers/license_attributes_helper.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,2 @@
+module LicenseAttributesHelper
+end

Added: trunk/app/helpers/licenses_helper.rb (0 => 2230)


--- trunk/app/helpers/licenses_helper.rb	                        (rev 0)
+++ trunk/app/helpers/licenses_helper.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,2 @@
+module LicensesHelper
+end

Modified: trunk/app/models/blob.rb (2229 => 2230)


--- trunk/app/models/blob.rb	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/models/blob.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -31,12 +31,13 @@
 
   belongs_to :content_blob
   belongs_to :content_type
+  belongs_to :license
+ 
 
   # :dependent => :destroy is not supported in belongs_to in rails 1.2.6
   after_destroy { |b| b.content_blob.destroy }
 
-  validates_inclusion_of :license, :in => [ "by-nd", "by-sa", "by" ]
-  
+  validates_presence_of :license_id
   validates_presence_of :content_blob
   validates_presence_of :content_type
 

Added: trunk/app/models/license.rb (0 => 2230)


--- trunk/app/models/license.rb	                        (rev 0)
+++ trunk/app/models/license.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,25 @@
+class License < ActiveRecord::Base
+  format_attribute :description
+
+  belongs_to :user
+
+  validates_presence_of :user_id, :title, :url
+  validates_uniqueness_of :title, :url
+  
+  has_many :license_attributes, 
+           :dependent => :destroy
+           
+   #def self.packs_with_contributable(contributable)
+   def self.find_license_options_set(license)
+     if license.id
+      license_id=license.id
+     else
+      license_id="0"
+     end
+     return LicenseOption.find_by_sql("SELECT license_options.title, license_options.id, lic_att.isset FROM license_options LEFT JOIN ( SELECT license_option_id, 1 AS isset FROM license_attributes WHERE license_id = #{license_id}) AS lic_att ON license_options.id = lic_att.license_option_id")
+  end
+  def license_attributes
+     return LicenseAttribute.find_by_sql("SELECT * FROM license_attributes INNER JOIN license_options on license_attributes.license_option_id=license_options.id WHERE license_id = #{self.id}")
+  end
+  
+end

Added: trunk/app/models/license_attribute.rb (0 => 2230)


--- trunk/app/models/license_attribute.rb	                        (rev 0)
+++ trunk/app/models/license_attribute.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,6 @@
+class LicenseAttribute < ActiveRecord::Base
+  belongs_to :license
+  belongs_to :license_option
+
+  validates_presence_of :license_option_id, :license_id
+end

Added: trunk/app/models/license_option.rb (0 => 2230)


--- trunk/app/models/license_option.rb	                        (rev 0)
+++ trunk/app/models/license_option.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,8 @@
+class LicenseOption < ActiveRecord::Base
+  format_attribute :description
+
+  belongs_to :user
+
+  validates_presence_of :user_id, :title, :uri, :predicate
+  validates_uniqueness_of :title, :uri
+end

Modified: trunk/app/models/workflow.rb (2229 => 2230)


--- trunk/app/models/workflow.rb	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/models/workflow.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -23,8 +23,8 @@
 
   belongs_to :content_blob
   belongs_to :content_type
-
-  
+  belongs_to :license
+    
   # need to destroy the workflow versions and their content blobs to avoid orphaned records
   before_destroy { |w| w.versions.each do |wv|
                         wv.content_blob.destroy if wv.content_blob
@@ -82,7 +82,7 @@
   end
   
   #non_versioned_fields.push("image", "svg", "license", "tag_list") # acts_as_versioned and file_column don't get on
-  non_versioned_columns.push("license", "tag_list", "body_html")
+  non_versioned_columns.push("license_id", "tag_list", "body_html")
   
   acts_as_solr(:fields => [ :title, :body, :tag_list, :contributor_name, :kind, :get_all_search_terms ],
                :boost => "search_boost",
@@ -97,8 +97,7 @@
   validates_presence_of :unique_name
   validates_uniqueness_of :unique_name
   
-  validates_inclusion_of :license, :in => [ "by-nd", "by-sa", "by" ]
-  
+  validates_presence_of :license_id
   validates_presence_of :content_blob
   validates_presence_of :content_type
 

Modified: trunk/app/views/blobs/_license_form.rhtml (2229 => 2230)


--- trunk/app/views/blobs/_license_form.rhtml	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/views/blobs/_license_form.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -1,9 +1,9 @@
-<% if params[:blob] && !params[:blob][:license].blank? %>
-	<% license = params[:blob][:license] %>
+<% if params[:blob] && !params[:blob][:license_id].blank? %>
+	<% @license = License.find(params[:blob][:license_id]) %>
 <% elsif edit %>
-	<% license = @blob.license %>
+	<% @license = License.find(@blob.license_id) %>
 <% else %>
- 	<% license = 'by-sa' %> 
+    <% @license = License.find(2) %>
 <% end %>
 
 <div class="fold">
@@ -12,10 +12,10 @@
       License/Rights
 			<% if edit %>
 				<hr />
-				<small>Current: <%= license_link(license) %></small>
+				<small>Current: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>) </small>
 			<% else %>
 				<hr />
-				<small>Default: people are allowed to build on this File, but must give author(s) credit and give attribution to this File. They must also share under the same conditions. (<%= license_link license %>)</small>
+				<small>Default: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>)</small>
 			<% end %>
     </div>
     <div class="foldContent" style="display: none;">
@@ -27,62 +27,16 @@
             <strong>What license do you want people to adhere to if they download and use this File?</strong>
         </p>
         <div style="padding-left: 1em;">
-            <div style="padding: 0.5em; border: 1px dotted #999999; margin: 1.5em 3em; text-align: center;">
-                <p style="text-align: center;">
-                    <img alt="Science Commons" src="" /></p>
-                <p style="text-align: center;">
-                    Below you can configure what rights people will have with this File, based on
-                    the <a href="" Commons</a>
-                    licenses. Sharing Files and letting others build upon them is a useful contribution
-                    and is highly recommended.</p>
-            </div>
-            <p>
-                When someone downloads this Files, are they allowed to build upon it (such as
-                extend, reuse, repurpose etc)?
-			</p>
-            <table style="border-collapse: collapse; border-spacing: 0;">
-            	<tbody>
-            		<tr>
-						<td style="vertical-align: top; text-align: center;">
-			                <input id="blob_license_bysa" <%= 'checked="checked"' if (license == 'by-sa') %> name="blob[license]" type="radio" value="by-sa"/>
-						</td>
-						<td style="vertical-align: top; text-align: left;">
-			                <p style="padding: 0; margin: 0;">
-			                	Yes, as long as they <strong>give the author(s) credit</strong> and <strong>give attribution to this File</strong>. 
-								They must also <strong>share</strong> the resulting work <strong>under the same conditions</strong>.
-								<br/>
-								- <%= license_link "by-sa" %>
-							</p>
-						</td>
-            		</tr>
-					<tr>
-						<td style="vertical-align: top; text-align: center;">
-                			<input id="blob_license_by" <%= 'checked="checked"' if (license == 'by') %> name="blob[license]" type="radio" value="by"/>
-						</td>
-						<td style="vertical-align: top; text-align: left;">	
-            				<p style="padding: 0; margin: 0;">
-            					Yes, as long as they <strong>give the author(s) credit</strong> and <strong>give attribution to this File</strong>.
-								<br/>
-								- <%= license_link "by" %>
-							</p>
-						</td>
-            		</tr>
-					<tr>
-						<td style="vertical-align: top; text-align: center;">
-                			<input id="blob_license_bynd" <%= 'checked="checked"' if (license == 'by-nd') %> name="blob[license]" type="radio" value="by-nd"/>
-						</td>
-						<td style="vertical-align: top; text-align: left;">
-            				<p style="padding: 0; margin: 0;">
-								No. They may only use the File for reference.
-								<br/>
-								- <%= license_link "by-nd" %>
-							</p>
-						</td>
-            		</tr>
-            	</tbody>
-        	</table>
-                <small>Nothing in these licenses impairs or restricts the author's moral rights.</small></p>
+        
+        <%= collection_select(:blob, :license_id, License.find(:all), :id, :title, {}, 
+              {: remote_function(:update => 'license_info',
+               :url ="" {:controller => 'licenses', :action="" 'update_license_info' },
+               :with => "'license_id=' + escape(value)")}) %>
         </div>
+        <hr/>
+        <div id="license_info" style="padding: 0 20px;">
+          <%= render :partial => "licenses/view", :locals => { :license => @license } %>
+		</div>
     </div>
 </div>
                 

Modified: trunk/app/views/blobs/_table.rhtml (2229 => 2230)


--- trunk/app/views/blobs/_table.rhtml	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/views/blobs/_table.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -61,7 +61,7 @@
 							</p>
 						<% end %>
 						
-						<p style="font-size:85%;"><b>License: </b><%= license_link blob.license.to_s %></p>
+						<p style="font-size:85%;"><b>License: </b><% @license = License.find(blob.license_id) %><%= link_to h(@license.url), license_path(@license) %></p>
 						
 						<div class="desc" style="font-size: 85%;">
 							<% if blob.body and blob.body.length > 0 %>

Modified: trunk/app/views/contributions/_license_box.rhtml (2229 => 2230)


--- trunk/app/views/contributions/_license_box.rhtml	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/views/contributions/_license_box.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -9,117 +9,42 @@
 
 
 <% dc_title = contributable.title %>
-<% dc_description = contributable.respond_to?('description_html') ? contributable.description_html : contributable.body_html %>
+<% dc_description = h(contributable.respond_to?('description_html') ? contributable.description_html : contributable.body_html) %>
 <% dc_date = contributable.created_at %>
 <% dc_creator = contributor(contributable.contribution.contributor_id, contributable.contribution.contributor_type, link=false)  %>
 <% dc_source = Conf.base_uri + request.request_uri %>
 
 
-<% case (contributable.license.to_s); when "by-nd" %>
+<% @license = License.find(contributable.license_id) %>
 
-<!--
+<%=  "<!--
 
-<rdf:RDF xmlns="http://web.resource.org/cc/"
-    xmlns:dc="http://purl.org/dc/elements/1.1/"
-    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-<Work rdf:about="">
-   <dc:title><%= dc_title %></dc:title>
-   <dc:date><%= dc_date %></dc:date>
-   <dc:description><%= dc_description %></dc:description>
+<rdf:RDF xmlns=\"http://creativecommons.org/ns#\"
+    xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
+    xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
+<Work rdf:about=\"\">
+   <dc:title>#{dc_title}</dc:title>
+   <dc:date>#{dc_date}</dc:date>
+   <dc:description>#{dc_description}</dc:description>
    <dc:creator><Agent>
-      <dc:title><%= dc_creator %></dc:title>
+      <dc:title>#{dc_creator}</dc:title>
    </Agent></dc:creator>
    <dc:rights><Agent>
-      <dc:title><%= dc_creator %></dc:title>
+      <dc:title>#{dc_creator}</dc:title>
    </Agent></dc:rights>
-   <dc:type rdf:resource="http://purl.org/dc/dcmitype/Data" />
-   <dc:source rdf:resource="<%= dc_source -%>"/>
-   <license rdf:resource="http://creativecommons.org/licenses/by-nd/3.0/" />
+   <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/Data\" />
+   <dc:source rdf:resource=\"#{dc_source}\"/>
+   <license rdf:resource=\"address@hidden" />
 </Work>
 
-<License rdf:about="http://creativecommons.org/licenses/by-nd/3.0/">
-   <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
-   <permits rdf:resource="http://web.resource.org/cc/Distribution" />
-   <requires rdf:resource="http://web.resource.org/cc/Notice" />
-   <requires rdf:resource="http://web.resource.org/cc/Attribution" />
-   <prohibits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+<License rdf:about=\"address@hidden">"%>
+<% @license.license_attributes.each do |attrib| %><%= "  <#{attrib.predicate} rdf:resource=\"#{attrib.uri}\" />" %><% end %>
 </License>
 
 </rdf:RDF>
 
 -->
 
-<% when "by-sa" %>
-
-<!--
-
-<rdf:RDF xmlns="http://web.resource.org/cc/"
-    xmlns:dc="http://purl.org/dc/elements/1.1/"
-    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-<Work rdf:about="">
-   <dc:title><%= dc_title %></dc:title>
-   <dc:date><%= dc_date %></dc:date>
-   <dc:description><%= dc_description %></dc:description>
-   <dc:creator><Agent>
-      <dc:title><%= dc_creator %></dc:title>
-   </Agent></dc:creator>
-   <dc:rights><Agent>
-      <dc:title><%= dc_creator %></dc:title>
-   </Agent></dc:rights>
-   <dc:type rdf:resource="http://purl.org/dc/dcmitype/Data" />
-   <dc:source rdf:resource="<%= dc_source -%>"/>
-   <license rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/" />
-</Work>
-
-<License rdf:about="http://creativecommons.org/licenses/by-sa/3.0/">
-   <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
-   <permits rdf:resource="http://web.resource.org/cc/Distribution" />
-   <requires rdf:resource="http://web.resource.org/cc/Notice" />
-   <requires rdf:resource="http://web.resource.org/cc/Attribution" />
-   <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
-   <requires rdf:resource="http://web.resource.org/cc/ShareAlike" />
-</License>
-
-</rdf:RDF>
-
--->
-
-<% when "by" %>
-
-<!--
-
-<rdf:RDF xmlns="http://web.resource.org/cc/"
-    xmlns:dc="http://purl.org/dc/elements/1.1/"
-    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-<Work rdf:about="">
-   <dc:title><%= dc_title %></dc:title>
-   <dc:date><%= dc_date %></dc:date>
-   <dc:description><%= dc_description %></dc:description>
-   <dc:creator><Agent>
-      <dc:title><%= dc_creator %></dc:title>
-   </Agent></dc:creator>
-   <dc:rights><Agent>
-      <dc:title><%= dc_creator %></dc:title>
-   </Agent></dc:rights>
-   <dc:type rdf:resource="http://purl.org/dc/dcmitype/Data" />
-   <dc:source rdf:resource="<%= dc_source -%>"/>
-   <license rdf:resource="http://creativecommons.org/licenses/by/3.0/" />
-</Work>
-
-<License rdf:about="http://creativecommons.org/licenses/by/3.0/">
-   <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
-   <permits rdf:resource="http://web.resource.org/cc/Distribution" />
-   <requires rdf:resource="http://web.resource.org/cc/Notice" />
-   <requires rdf:resource="http://web.resource.org/cc/Attribution" />
-   <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
-</License>
-
-</rdf:RDF>
-
--->
-
-<% end %>
-
   <div class="contribution_currentlicense">
     <p>
       <% if contributable.respond_to?('versions') %>
@@ -127,7 +52,7 @@
       <% else %>
         This <%= visible_name(contributable) -%> is
       <% end %>
-      licensed under the <%= license_link contributable.license.to_s %>.
+      licensed under: <br/><br/><%= license_icon_link(@license) %>
     </p>
   </div>
 	

Added: trunk/app/views/license_attributes/_add_attribute.rhtml (0 => 2230)


--- trunk/app/views/license_attributes/_add_attribute.rhtml	                        (rev 0)
+++ trunk/app/views/license_attributes/_add_attribute.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,8 @@
+<p><b>Add Attribute: </b>
+<select id="license_options_dropdown">
+  <% LicenseOption.find(:all).each do |f| %>
+    <option value="<%= f.id %>"><%= h(f.title) %></option>
+  <% end %>
+</select>
+<b>&nbsp;<a href=""  document.getElementById('license_options_dropdown').value = ''; return false;">Add</a></b>
+</p>
\ No newline at end of file

Added: trunk/app/views/license_attributes/_attribute.rhtml (0 => 2230)


--- trunk/app/views/license_attributes/_attribute.rhtml	                        (rev 0)
+++ trunk/app/views/license_attributes/_attribute.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,4 @@
+<li>
+  <b><%=h attribute.license_option.title %></b> - <%=h attribute.license_option.description %>
+</li>
+

Added: trunk/app/views/license_attributes/_attributes_form.rhtml (0 => 2230)


--- trunk/app/views/license_attributes/_attributes_form.rhtml	                        (rev 0)
+++ trunk/app/views/license_attributes/_attributes_form.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,25 @@
+
+<div class="fold">
+  <div class="foldTitle">
+  	<%= info_icon_with_tooltip("Here you can add attributes to <strong>describe</strong> this license.") %>
+		<span>Attributes</span>
+		<% if edit %>
+			<hr />
+			<small>Current: <%= license.license_attributes.count %> attributes</small>
+		<% end %>
+  </div>
+  
+  <div class="foldContent">
+  <p><strong>Choose the attributes you want for this license:</strong></p>
+     <div id="license_options_box" class="box_editing" style="padding-left: 1em; font-size: 93%;">
+     <% License.find_license_options_set(@license).each do |a| %>
+       <p>
+	     <label for="" a.id %>">
+		   <input <%= 'checked' if a.isset %> style="margin-right: 0.3em;" value="<%= a.id %>" type="checkbox" name="license_attributes[<%= a.id %>][id]" id="license_attributes_<%= a.id %> " />
+	       <%= h(a.title) %>
+	     </label>
+	   </p>
+     <% end %>
+    </div>
+  </div>
+</div>

Added: trunk/app/views/licenses/_breadcrumbs.rhtml (0 => 2230)


--- trunk/app/views/licenses/_breadcrumbs.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/_breadcrumbs.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,17 @@
+<li><%= link_to 'Licenses', licenses_path -%></li>
+
+<% if ["show", "new", "edit"].include? controller.action_name.to_s -%>
+  <li><b>&#187;</b></li>
+  
+  <% case controller.action_name.to_s; when "show" %>
+    <li><%= h(@license.title) -%></li>
+  <% when "new" %>
+    <li>New License</li>
+  <% when "edit" %>
+		<li><%= link_to "#{h(@license.title)}", license_path(@license) -%></li>
+		<li><b>&#187;</b></li>
+    <li>Edit</li>
+  <% else %>
+    <!-- no breadcrumb -->
+  <% end %>
+<% end %>

Added: trunk/app/views/licenses/_form.rhtml (0 => 2230)


--- trunk/app/views/licenses/_form.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/_form.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,21 @@
+<%= _javascript__include_tag :fckeditor %>
+<%= _javascript__include_tag 'license_attributes' %>
+
+<!--[form:license]-->
+<p><label for="" Name</label><br/>
+<%= form.text_field :unique_name, :size => 20 %></p>
+
+<p><label for=""
+<%= form.text_field :title, :size => 70 %></p>
+
+<p><label for=""
+<%= form.text_field :url, :size => 70 %></p>
+
+<br/>
+<%= render :partial => "license_attributes/attributes_form", :locals => { :edit => true, :license => @license } %>
+
+<h2><label for=""
+<%= fckeditor_textarea(:license, :description, :toolbarSet => 'Simple', :width => '700px', :height => '300px') %></p>
+<br/><br/>
+
+<!--[eoform:license]-->
\ No newline at end of file

Added: trunk/app/views/licenses/_table.rhtml (0 => 2230)


--- trunk/app/views/licenses/_table.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/_table.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,42 @@
+<% unless collection.empty? %>
+
+	<table class="alt_table">
+		<% odd_row = false -%> 
+		<% for license in collection %>
+		  	<tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
+			    <td width="100px">
+						<%= contributor(license.user_id, 'User', true, 60) %>
+					</td>
+			    <td class="mid" style="text-align: left;">
+			    	<p style="margin-top:0; padding-top:0; font-weight:bold; font-size: 108%;">
+							<%= icon "license", nil, nil, nil, '' %>
+							<%= link_to h(license.title), license_url(license) %>
+						</p>
+						
+						<p style="font-size: 85%;">
+							<b><%= datetime license.created_at %></b>
+						</p>
+						
+						<p style="font-size: 85%;">
+							<b><%= link_to h(license.url), license.url %></b>
+						</p>
+						
+						<% if license.description_html and license.description_html.length > 0 %>
+							<div class="desc" style="font-size: 85%;">
+								<%= truncate(strip_html(license.description_html), 180) %>
+							</div>
+						<% end %>
+						
+					</td>
+			    <td class="actions"  style="width: 80px;">
+		      	<%= icon "show", license_path(license), nil, nil, "View" %>
+						<% if admin? %>
+							<%= icon('edit', edit_license_path(license), nil, nil, 'Edit') %>
+							<%= icon('destroy', license_path(license), nil, { :confirm => 'Are you sure you want to delete this license?', :method => :delete }, 'Delete') %>
+						<% end %>
+		    	</td>
+		  	</tr>
+		<% end %>
+	</table>
+
+<% end %>

Added: trunk/app/views/licenses/_view.rhtml (0 => 2230)


--- trunk/app/views/licenses/_view.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/_view.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,15 @@
+                <p style="text-align: center;">
+                  <b><big><%= license_icon_link(license) %></big></b>
+                  <br/>
+                  <%= link_to h(license.url), license.url %>
+                </p>
+                <% license_attribs = license.license_attributes %>
+                <% if license_attribs.size > 0 %>
+                <p><b>Attributes:&nbsp;</b>
+                  <% license_attribs.each do | attrib | %>
+				    <%= attrib.title %><% if attrib != license_attribs.last %>,<% else %>.<% end %>
+				  <% end %>
+				</p>
+				<% end %>
+		        <br/>
+				<small><%= license.description %></small>
\ No newline at end of file

Added: trunk/app/views/licenses/edit.rhtml (0 => 2230)


--- trunk/app/views/licenses/edit.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/edit.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,8 @@
+<h1>Editing License</h1>
+
+<%= error_messages_for :license %>
+
+<%  form_for(:license, :url ="" license_path(@license), :html => { :method => :put }) do |form| %>
+  <%= render :partial => 'form', :object => form %>
+  <%= submit_tag 'Update', :disable_with => "Updating..." %>
+<% end %>
\ No newline at end of file

Added: trunk/app/views/licenses/index.rhtml (0 => 2230)


--- trunk/app/views/licenses/index.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/index.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,11 @@
+<h1>
+	Licenses (<%= @licenses.length %>)
+</h1>
+
+<% if admin? %>
+	<ul class="sectionIcons">
+	  <li><%= icon('license', new_license_path, nil, nil, 'New License') %></li>
+	</ul>
+<% end %>
+
+<%= render :partial => "licenses/table", :locals => { :collection => @licenses } %>

Added: trunk/app/views/licenses/new.rhtml (0 => 2230)


--- trunk/app/views/licenses/new.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/new.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,8 @@
+<h1>New License</h1>
+
+<%= error_messages_for :license %>
+
+<% form_for :license, :url ="" licenses_path do |form| -%>
+  <%= render :partial => 'form', :object => form %>
+  <%= submit_tag "Create", :disable_with => "Creating..." %>
+<% end -%>
\ No newline at end of file

Added: trunk/app/views/licenses/show.rhtml (0 => 2230)


--- trunk/app/views/licenses/show.rhtml	                        (rev 0)
+++ trunk/app/views/licenses/show.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,38 @@
+<% t "#{h @license.title}" -%>
+
+<h1>License: <%= h @license.title %></h1>
+
+<% if admin? %>
+	<ul class="sectionIcons">
+	  <li><%= icon('edit', edit_license_path(@license), nil, nil, 'Edit') %></li>
+		<li>
+			<%= icon('destroy', license_path(@license), nil, { :confirm => 'Are you sure you want to delete this license?', :method => :delete }, 'Delete') %>
+		</li>
+	</ul>
+<% end %>
+
+<div class="message_box">
+	<div style="float: left;">
+		<p style="text-align: center;"><b>By</b></p>
+		<%= render :partial => "users/avatar", :locals => { :user => @license.user, :size => 60 } %>
+	</div>
+	
+	<div style="float: left; margin-left: 3em; width: 550px;">
+		<p><b>Title</b></p>
+		<p class="subject">
+			<%=h @license.title %>
+		</p>
+		<p><b>URL: </b><%= link_to h(@license.url), @license.url %></p>
+		<p><b>Created: </b><%=datetime @license.created_at %></p>
+		<p><b>Updated: </b><%=datetime @license.updated_at %></p>
+	</div>
+    <div class="clearer">&nbsp;</div>
+    <h2>Attributes</h2>
+	<% unless @license.attributes.empty? %>
+      <ul><%= render :partial => "license_attributes/attribute", :collection => LicenseAttribute.find(:all, :conditions => ["license_id = ?", @license.id], :order => "license_option_id") %></ul>
+    <% end %> 
+	<h2>Description</h2>
+	<div class="message">
+		<%= @license.description_html %>
+	</div>
+</div>

Modified: trunk/app/views/workflows/_license_form.rhtml (2229 => 2230)


--- trunk/app/views/workflows/_license_form.rhtml	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/views/workflows/_license_form.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -1,90 +1,42 @@
-<% if params[:workflow] && !params[:workflow][:license].blank? %>
-	<% license = params[:workflow][:license] %>
+<% if params[:workflow] && !params[:workflow][:license_id].blank? %>
+	<% @license = License.find(params[:workflow][:license_id]) %>
 <% elsif edit %>
-	<% license = @workflow.license %>
+	<% @license = License.find(@workflow.license_id) %>
 <% else %>
- 	<% license = 'by-sa' %> 
+    <% @license = License.find(2) %>
 <% end %>
 
 <div class="fold">
     <div class="foldTitle">
-        <%= info_icon_with_tooltip("This section allows you to specify the <strong>rights</strong> that people have when they download and use this Workflow, by setting the license. <br/><br/>By default, the license specifies that people are allowed to build on this Workflow as long as they give the original author credit and share their resulting work under the same conditions.") %>
-        License/Rights
-		<% if edit %>
-			<hr />
-			<small>Current: <%= license_link(license) %></small>
-		<% else %>
-			<hr />
-			<small>Default: people are allowed to build on this Workflow, but must give author(s) credit and give attribution to this Workflow. They must also share under the same conditions. (<%= license_link license %>)</small>
-		<% end %>
+      <%= info_icon_with_tooltip("This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license. <br/><br/>By default, the license specifies that people are allowed to build on this File as long as they give the original author credit and share their resulting work under the same conditions.") %>
+      License/Rights
+			<% if edit %>
+				<hr />
+				<small>Current: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>) </small>
+			<% else %>
+				<hr />
+				<small>Default: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>)</small>
+			<% end %>
     </div>
     <div class="foldContent" style="display: none;">
         <p class="box_infotext">
-            This section allows you to specify the <strong>rights</strong> that people have when they download and use this Workflow, by setting the license.
+            This section allows you to specify the <strong>rights</strong> that people have when they download and use this File, by setting the license.
         </p>
         <br />
         <p>
-            <strong>What license do you want people to adhere to if they download and use this Workflow?</strong>
+            <strong>What license do you want people to adhere to if they download and use this File?</strong>
         </p>
         <div style="padding-left: 1em;">
-            <div style="padding: 0.5em; border: 1px dotted #999999; margin: 1.5em 3em; text-align: center;">
-                <p style="text-align: center;">
-                    <img alt="Science Commons" src="" /></p>
-                <p style="text-align: center;">
-                    Below you can configure what rights people will have with this Workflow, based on
-                    the <a href="" Commons</a>
-                    licenses. Sharing Workflows and letting others build upon them is a useful contribution
-                    and is highly recommended.</p>
-            </div>
-            <p>
-                When someone downloads this Workflow, are they allowed to build upon it (such as
-                extend, reuse, repurpose etc)?
-						</p>
-            <table style="border-collapse: collapse; border-spacing: 0;">
-            	<tbody>
-            		<tr>
-						<td style="vertical-align: top; text-align: center;">
-			                <input id="workflow_license_bysa" <%= 'checked="checked"' if (license == 'by-sa') %> name="workflow[license]" type="radio" value="by-sa"/>
-						</td>
-						<td style="vertical-align: top; text-align: left;">
-			                <p style="padding: 0; margin: 0;">
-			                	<label for="" as long as they <strong>give the author(s) credit</strong> and <strong>give attribution to this Workflow</strong>. 
-								They must also <strong>share</strong> the resulting work <strong>under the same conditions</strong>.</label>
-								<br/>
-								- <%= license_link "by-sa" %>
-							</p>
-						</td>
-            		</tr>
-					<tr>
-						<td style="vertical-align: top; text-align: center;">
-                			<input id="workflow_license_by" <%= 'checked="checked"' if (license == 'by') %> name="workflow[license]" type="radio" value="by"/>
-						</td>
-						<td style="vertical-align: top; text-align: left;">	
-            				<p style="padding: 0; margin: 0;"><label for=""
-            					Yes, as long as they <strong>give the author(s) credit</strong> and <strong>give attribution to this Workflow</strong>.
-										</label>
-								<br/>
-								- <%= license_link "by" %>
-							</p>
-						</td>
-            		</tr>
-					<tr>
-						<td style="vertical-align: top; text-align: center;">
-                			<input id="workflow_license_bynd" <%= 'checked="checked"' if (license == 'by-nd') %> name="workflow[license]" type="radio" value="by-nd"/>
-						</td>
-						<td style="vertical-align: top; text-align: left;">
-            				<p style="padding: 0; margin: 0;"><label for=""
-								No. They may only use the Workflow for reference.
-								    </label>
-								<br/>
-								- <%= license_link "by-nd" %>
-							</p>
-						</td>
-            		</tr>
-            	</tbody>
-        	</table>
-                <small>Nothing in these licenses impairs or restricts the author's moral rights.</small></p>
+        
+        <%= collection_select(:workflow, :license_id, License.find(:all), :id, :title, {}, 
+              {: remote_function(:update => 'license_info',
+               :url ="" {:controller => 'licenses', :action="" 'update_license_info' },
+               :with => "'license_id=' + escape(value)")}) %>
         </div>
+        <hr/>
+        <div id="license_info" style="padding: 0 20px;">
+          <%= render :partial => "licenses/view", :locals => { :license => @license } %>
+		</div>
     </div>
 </div>
                 

Modified: trunk/app/views/workflows/_table.rhtml (2229 => 2230)


--- trunk/app/views/workflows/_table.rhtml	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/app/views/workflows/_table.rhtml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -68,7 +68,7 @@
 					  	</p>
 					  <% end %>
 						
-						<p style="font-size:85%;"><b>License: </b><%= license_link workflow.license.to_s %></p>
+						<p style="font-size:85%;"><b>License: </b><% @license = License.find(workflow.license_id) %><%= link_to h(@license.url), license_path(@license) %></p>
 					  
 						<table style="width: 99%;">
 							<tbody>

Modified: trunk/config/routes.rb (2229 => 2230)


--- trunk/config/routes.rb	2009-06-15 14:54:22 UTC (rev 2229)
+++ trunk/config/routes.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -206,6 +206,9 @@
   # before 'announcements' resource within 'groups'
   map.resources :announcements
 
+  map.resources :licenses
+  map.resources :license_attributes
+
   # Install the default route as the lowest priority.
   map.connect ':controller/:action/:id'
 end

Added: trunk/db/migrate/077_create_licenses.rb (0 => 2230)


--- trunk/db/migrate/077_create_licenses.rb	                        (rev 0)
+++ trunk/db/migrate/077_create_licenses.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,224 @@
+class CreateLicenses < ActiveRecord::Migration
+  def self.up
+    create_table :licenses do |t|
+      t.column :user_id, :integer
+      t.column :unique_name, :string
+      t.column :title, :string
+      t.column :description, :text
+      t.column :description_html, :text
+      t.column :url, :string
+      t.column :created_at, :datetime
+      t.column :updated_at, :datetime
+    end
+  u = User.find_by_username(Conf.admins.first)
+  
+  #by-nd
+  License.create(:user => u, :unique_name => 'by-nd', :title => 'Creative Commons Attribution-No Derivative Works 3.0 Unported License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>Attribution &mdash; You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</li>
+  <li>No Derivative Works &mdash; You may not alter, transform, or build upon this work.</li>
+</ul>
+<h4>With the understanding that:</h4>
+<ul>
+  <li>Waiver &mdash; Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+  <li>Other Rights &mdash; In no way are any of the following rights affected by the license:
+    <ul>
+      <li>Your fair dealing or fair use rights;</li>
+      <li>The author's moral rights;</li>
+      <li>Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.</li>
+    </ul>
+  </li>
+  <li>Notice &mdash; For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to <a href=''>http://creativecommons.org/licenses/by-nd/3.0/</a>.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/by-nd/3.0/')
+ 
+ #by-sa
+ License.create(:user => u, :unique_name => 'by-sa', :title => 'Creative Commons Attribution-Share Alike 3.0 Unported License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+  <li>to Remix &mdash; to adapt the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>Attribution &mdash; You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</li>
+  <li>Share Alike &mdash; If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.</li>
+</ul>
+
+<h4>With the understanding that:</h4>
+<ul>
+  <li>Waiver &mdash; Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+  <li>Other Rights &mdash; In no way are any of the following rights affected by the license:
+    <ul>
+      <li>Your fair dealing or fair use rights;</li>
+      <li>The author's moral rights;</li>
+      <li>Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.</li>
+    </ul>
+  </li>
+  <li>Notice &mdash; For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to <a href=''>http://creativecommons.org/licenses/by-sa/3.0/</a>.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/by-sa/3.0/')
+
+#by
+ License.create(:user => u, :unique_name => 'by', :title => 'Creative Commons Attribution 3.0 Unported License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+  <li>to Remix &mdash; to adapt the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>Attribution &mdash; You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</li>
+</ul>
+<h4>With the understanding that:</h4>
+<ul>
+  <li>Waiver &mdash; Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+  <li>Other Rights &mdash; In no way are any of the following rights affected by the license:
+    <ul>
+      <li>Your fair dealing or fair use rights;</li>
+      <li>The author's moral rights;</li>
+      <li>Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.</li>
+    </ul>
+  </li>
+  <li>Notice &mdash; For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to <a href=''>http://creativecommons.org/licenses/by/3.0/</a>.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/by/3.0/')
+
+
+#by-nc-nd
+ License.create(:user => u, :unique_name => 'by-nc-nd', :title => 'Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>Attribution &mdash; You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</li>
+  <li>Noncommercial &mdash; You may not use this work for commercial purposes.</li>
+  <li>No Derivative Works &mdash; You may not alter, transform, or build upon this work.</li>
+</ul>
+<h4>With the understanding that:</h4>
+<ul>
+  <li>Waiver &mdash; Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+  <li>Other Rights &mdash; In no way are any of the following rights affected by the license:
+    <ul>
+      <li>Your fair dealing or fair use rights;</li>
+      <li>The author's moral rights;</li>
+      <li>Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.</li>
+    </ul>
+  </li>
+  <li>Notice &mdash; For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to <a href=''>http://creativecommons.org/licenses/by-nc-nd/3.0/</a>.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/by-nc-nd/3.0/')
+
+#by-nc
+ License.create(:user => u, :unique_name => 'by-nc', :title => 'Creative Commons Attribution-Noncommercial 3.0 Unported License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+  <li>to Remix &mdash; to adapt the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>Attribution &mdash; You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</li>
+  <li>Noncommercial &mdash; You may not use this work for commercial purposes.</li>
+</ul>
+<h4>With the understanding that:</h4>
+<ul>
+  <li>Waiver &mdash; Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+  <li>Other Rights &mdash; In no way are any of the following rights affected by the license:
+    <ul>
+      <li>Your fair dealing or fair use rights;</li>
+      <li>The author's moral rights;</li>
+      <li>Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.</li>
+    </ul>
+  </li>
+  <li>Notice &mdash; For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to <a href=''>http://creativecommons.org/licenses/by-nc/3.0/</a>.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/by-nc/3.0/')
+
+#by-nc-sa
+License.create(:user => u, :unique_name => 'by-nc-sa', :title => 'Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+  <li>to Remix &mdash; to adapt the work</li>
+</ul>  
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>Attribution &mdash; You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).</li>
+  <li>Noncommercial &mdash; You may not use this work for commercial purposes.</li>
+  <li>Share Alike &mdash; If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.</li>
+</ul>
+<h4>With the understanding that:</h4>
+<ul>
+  <li>Waiver &mdash; Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+  <li>Other Rights &mdash; In no way are any of the following rights affected by the license:
+    <ul>
+      <li>Your fair dealing or fair use rights;</li>
+      <li>The author's moral rights;</li>
+      <li>Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.</li>
+    </ul>
+  </li>
+  <li>Notice &mdash; For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to <a href=''>http://creativecommons.org/licenses/by-nc-sa/3.0/</a>.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/by-nc-sa/3.0/')
+
+#MIT
+License.create(:user => u, :unique_name => 'MIT', :title => 'MIT License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+  <li>to Remix &mdash; to adapt the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>The copyright notice and license shall be included in all copies or substantial portions of the software.</li>
+  <li>Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/MIT/')
+
+#BSD
+License.create(:user => u, :unique_name => 'BSD', :title => 'BSD License', :description => "<h4>You are free:</h4>
+<ul>
+  <li>to Share &mdash; to copy, distribute and transmit the work</li>
+  <li>to Remix &mdash; to adapt the work</li>
+</ul>
+<h4>Under the following conditions:</h4>
+<ul>
+  <li>No Endorsement. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.</li>
+  <li>You must retain the license terms and copyright notice in any source code distribution and reproduce them in documentation for binary distributions.</li>
+  <li>Any of the above conditions can be waived if you get permission from the copyright holder.</li>
+</ul>", :url ="" 'http://creativecommons.org/licenses/BSD/')
+
+#GPL
+License.create(:user => u, :unique_name => 'GPL', :title => 'GNU General Public License (GPL) 2.0', :description => "<p>The GNU General Public License is a Free Software license. Like any Free Software license, it grants to you the four following freedoms:</p>
+<ol>
+  <li>The freedom to run the program for any purpose.</li>
+  <li>The freedom to study how the program works and adapt it to your needs.</li>
+  <li>The freedom to redistribute copies so you can help your neighbor.</li>
+  <li>The freedom to improve the program and release your improvements to the public, so that the whole community benefits.</li>
+</ol>
+<p>You may exercise the freedoms specified here provided that you comply with the express conditions of this license. The principal conditions are:</p>
+<ul>
+  <li>You must conspicuously and appropriately publish on each copy distributed an appropriate copyright notice and disclaimer of warranty and keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of the GNU General Public License along with the Program. Any translation of the GNU General Public License must be accompanied by the GNU General Public License.</li>
+  <li>If you modify your copy or copies of the program or any portion of it, or develop a program based upon it, you may distribute the resulting work provided you do so under the GNU General Public License. Any translation of the GNU General Public License must be accompanied by the GNU General Public License.</li>
+  <li>If you copy or distribute the program, you must accompany it with the complete corresponding machine-readable source code or with a written offer, valid for at least three years, to furnish the complete corresponding machine-readable source code.</li>
+</ul>
+<p>Any of the above conditions can be waived if you get permission from the copyright holder.</p>", :url ="" 'http://creativecommons.org/licenses/GPL/2.0/')
+
+#LGPL
+License.create(:user => u, :unique_name => 'LGPL', :title => 'GNU Lesser General Public License (LGPL) 2.1', :description => "<p>The GNU Lesser General Public License is a Free Software license. Like any Free Software license, it grants to you the four following freedoms:</p>
+<ol>
+  <li>The freedom to run the program for any purpose.</li>
+  <li>The freedom to study how the program works and adapt it to your needs.</li>
+  <li>The freedom to redistribute copies so you can help your neighbor.</li>
+  <li>The freedom to improve the program and release your improvements to the public, so that the whole community benefits.</li>
+</ol>
+<p>You may exercise the freedoms specified here provided that you comply with the express conditions of this license. The LGPL is intended for software libraries, rather than executable programs. The principal conditions are:<p>
+<ul>
+  <li>You must conspicuously and appropriately publish on each copy distributed an appropriate copyright notice and disclaimer of warranty and keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of the GNU Lesser General Public License along with the Program. Any translation of the GNU Lesser General Public License must be accompanied by the GNU Lesser General Public License.</li>
+  <li>If you modify your copy or copies of the library or any portion of it, you may distribute the resulting library provided you do so under the GNU Lesser General Public License. However, programs that link to the library may be licensed under terms of your choice, so long as the library itself can be changed. Any translation of the GNU Lesser General Public License must be accompanied by the GNU Lesser General Public License.</li>
+  <li>If you copy or distribute the program, you must accompany it with the complete corresponding machine-readable source code or with a written offer, valid for at least three years, to furnish the complete corresponding machine-readable source code.</li>
+</ul>
+<p>Any of the above conditions can be waived if you get permission from the copyright holder.</p>", :url ="" 'http://creativecommons.org/licenses/LGPL/2.1/')
+  
+ #Apache
+ License.create(:user => u, :unique_name => 'Apache', :title => 'Apache License v2.0', :description => "<p>See <a href=''>http://www.apache.org/licenses/LICENSE-2.0</a></p>", :url ="" "http://www.apache.org/licenses/LICENSE-2.0")
+ end
+ 
+ def self.down
+    drop_table :licenses
+  end
+end

Added: trunk/db/migrate/078_create_license_options.rb (0 => 2230)


--- trunk/db/migrate/078_create_license_options.rb	                        (rev 0)
+++ trunk/db/migrate/078_create_license_options.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,32 @@
+class CreateLicenseOptions < ActiveRecord::Migration
+  def self.up
+    create_table :license_options do |t|
+      t.column :user_id, :integer
+      t.column :title, :string
+      t.column :description, :text
+      t.column :description_html, :text
+      t.column :uri, :string
+      t.column :predicate, :string
+      t.column :created_at, :datetime
+      t.column :updated_at, :datetime
+    end
+    u = User.find_by_username(Conf.admins.first)
+
+    LicenseOption.create(:user => u, :title => 'Permits Reproduction', :description => 'Permits making multiple copies', :uri => 'http://creativecommons.org/ns#Reproduction', :predicate => 'permits')
+    LicenseOption.create(:user => u, :title => 'Permits Distribution', :description => 'Permits distribution, public display, and publicly performance', :uri => 'http://creativecommons.org/ns#Distribution', :predicate => 'permits')
+    LicenseOption.create(:user => u, :title => 'Permits Derivative Works', :description => 'Permits distribution of derivative works', :uri => 'http://creativecommons.org/ns#DerivativeWorks', :predicate => 'permits')
+    LicenseOption.create(:user => u, :title => 'Permits High Income Nation Use', :description => 'Permits use in a non-developing country', :uri => 'http://creativecommons.org/ns#HighIncomeNationUse', :predicate => 'permits')
+    LicenseOption.create(:user => u, :title => 'Permits Sharing', :description => 'Permits commercial derivatives, but only non-commercial distribution', :uri => 'http://creativecommons.org/ns#Sharing', :predicate => 'permits')
+    LicenseOption.create(:user => u, :title => 'Requires Notice', :description => 'Requries copyright and license notices be kept intact', :uri => 'http://creativecommons.org/ns#Notice', :predicate => 'requires')
+    LicenseOption.create(:user => u, :title => 'Requires Attribution', :description => 'Requires credit be given to copyright holder and/or author', :uri => 'http://creativecommons.org/ns#Attribution', :predicate => 'requires')
+    LicenseOption.create(:user => u, :title => 'Requires Share Alike', :description => 'Requires derivative works be licensed under the same terms or compatible terms as the original work', :uri => 'http://creativecommons.org/ns#ShareAlike', :predicate => 'requires')
+    LicenseOption.create(:user => u, :title => 'Requires Source Code', :description => 'Requires source code (the preferred form for making modifications) must be provided when exercising some rights granted by the license.', :uri => 'http://creativecommons.org/ns#SourceCode', :predicate => 'requires')
+    LicenseOption.create(:user => u, :title => 'Requires Copyleft', :description => 'Requires derivative and combined works must be licensed under specified terms, similar to those on the original work', :uri => 'http://creativecommons.org/ns#Copyleft', :predicate => 'requires')
+    LicenseOption.create(:user => u, :title => 'Requires Lesser Copyleft', :description => 'Requires derivative works must be licensed under specified terms, with at least the same conditions as the original work; combinations with the work may be licensed under different terms', :uri => 'http://creativecommons.org/ns#LesserCopyleft', :predicate => 'requires')
+    LicenseOption.create(:user => u, :title => 'Prohibits Commercial User', :description => 'Prohibits exercising rights for commercial purposes', :uri => 'http://creativecommons.org/ns#CommercialUse', :predicate => 'prohibits')
+  end
+
+  def self.down
+    drop_table :license_options
+  end
+end

Added: trunk/db/migrate/079_create_license_attributes.rb (0 => 2230)


--- trunk/db/migrate/079_create_license_attributes.rb	                        (rev 0)
+++ trunk/db/migrate/079_create_license_attributes.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,97 @@
+class CreateLicenseAttributes < ActiveRecord::Migration
+  def self.up
+    create_table :license_attributes do |t|
+      t.column :license_id, :integer
+      t.column :license_option_id, :integer
+      t.column :created_at, :datetime
+    end
+    reproduction = LicenseOption.find(:first,:conditions=>['title = ?','Permits Reproduction'])
+    distribution = LicenseOption.find(:first,:conditions=>['title = ?','Permits Distribution'])
+    derivs = LicenseOption.find(:first,:conditions=>['title = ?','Permits Derivative Works'])
+    notice = LicenseOption.find(:first,:conditions=>['title = ?','Requires Notice'])
+    attribution = LicenseOption.find(:first,:conditions=>['title = ?','Requires Attribution'])
+    sharealike = LicenseOption.find(:first,:conditions=>['title = ?','Requires Share Alike'])
+    sourcecode = LicenseOption.find(:first,:conditions=>['title = ?','Requires Source Code'])
+    commercial = LicenseOption.find(:first,:conditions=>['title = ?','Prohibits Commercial Use'])
+    
+    #by-nd
+    lic = License.find(:first,:conditions=>['unique_name = ?','by-nd'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => attribution )
+    lic.save
+    
+    #by-sa
+    lic = License.find(:first,:conditions=>['unique_name = ?','by-sa'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => attribution )
+    LicenseAttribute.create(:license => lic, :license_option => derivs )
+    LicenseAttribute.create(:license => lic, :license_option => sharealike )
+    lic.save
+    
+    #by
+    lic = License.find(:first,:conditions=>['unique_name = ?','by'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => attribution )
+    LicenseAttribute.create(:license => lic, :license_option => derivs )
+    lic.save
+    
+    #by-nc-nd
+    lic = License.find(:first,:conditions=>['unique_name = ?','by-nc-nd'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => attribution )
+    LicenseAttribute.create(:license => lic, :license_option => commercial )
+    lic.save
+    
+    #by-nc
+    lic = License.find(:first,:conditions=>['unique_name = ?','by-nc'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => attribution )
+    LicenseAttribute.create(:license => lic, :license_option => commercial )
+    LicenseAttribute.create(:license => lic, :license_option => derivs )
+    lic.save
+    
+    #by-nc-sa
+    lic = License.find(:first,:conditions=>['unique_name = ?','by-nc-sa'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => attribution )
+    LicenseAttribute.create(:license => lic, :license_option => commercial )
+    LicenseAttribute.create(:license => lic, :license_option => derivs )
+    LicenseAttribute.create(:license => lic, :license_option => sharealike )
+    lic.save
+    
+    #MIT
+    lic = License.find(:first,:conditions=>['unique_name = ?','MIT'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => sourcecode )
+    LicenseAttribute.create(:license => lic, :license_option => derivs )
+    lic.save
+    
+    #BSD
+    lic = License.find(:first,:conditions=>['unique_name = ?','BSD'])
+    LicenseAttribute.create(:license => lic, :license_option => reproduction )
+    LicenseAttribute.create(:license => lic, :license_option => distribution )
+    LicenseAttribute.create(:license => lic, :license_option => notice )
+    LicenseAttribute.create(:license => lic, :license_option => sourcecode )
+    LicenseAttribute.create(:license => lic, :license_option => derivs )
+    lic.save
+    
+  end
+
+  def self.down
+    drop_table :license_attributes
+  end
+end

Added: trunk/db/migrate/080_add_license_id_to_workflows_and_blobs.rb (0 => 2230)


--- trunk/db/migrate/080_add_license_id_to_workflows_and_blobs.rb	                        (rev 0)
+++ trunk/db/migrate/080_add_license_id_to_workflows_and_blobs.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,37 @@
+class AddLicenseIdToWorkflowsAndBlobs < ActiveRecord::Migration
+  def self.up
+    #Need to rename columns so that license method and license field do not get confused
+    rename_column :workflows, :license, :license_name
+    rename_column :blobs, :license, :license_name
+    
+    add_column :workflows, :license_id, :integer, :default => nil
+    add_column :blobs, :license_id, :integer, :default => nil
+    
+    Workflow.find(:all).each do |w|
+      execute("UPDATE workflows SET license_id = #{License.find(:first,:conditions=>[ 'unique_name = ?', w.license_name ]).id } WHERE id = #{w.id}")
+    end
+    Blob.find(:all).each do |b|
+      execute("UPDATE blobs SET license_id = #{License.find(:first,:conditions=>[ 'unique_name = ?', b.license_name ]).id } WHERE id = #{b.id}")
+    end 
+    remove_column :workflows, :license_name
+    remove_column :blobs, :license_name
+  end
+  
+  def self.down
+    add_column :workflows, :license, :string, 
+               :limit => 10, :null => false, 
+               :default => "by-sa"
+               
+    add_column :blobs, :license, :string, 
+               :limit => 10, :null => false, 
+               :default => "by-sa"
+    Workflow.find(:all).each do |w|
+      execute("UPDATE workflows SET license = '#{License.find(w.license_id).unique_name }' WHERE id = #{w.id}")
+    end
+    Blob.find(:all).each do |b|
+      execute("UPDATE blobs SET license = '#{License.find(b.license_id).unique_name }' WHERE id = #{b.id}")
+    end
+    remove_column :workflows, :license_id
+    remove_column :blobs, :license_id
+  end
+end
\ No newline at end of file

Added: trunk/public/images/GPL.png


(Binary files differ)
Property changes on: trunk/public/images/GPL.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/LGPL.png


(Binary files differ)
Property changes on: trunk/public/images/LGPL.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/by-nc-nd.png


(Binary files differ)
Property changes on: trunk/public/images/by-nc-nd.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/by-nc-sa.png


(Binary files differ)
Property changes on: trunk/public/images/by-nc-sa.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/by-nc.png


(Binary files differ)
Property changes on: trunk/public/images/by-nc.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/by-nd.png


(Binary files differ)
Property changes on: trunk/public/images/by-nd.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/by-sa.png


(Binary files differ)
Property changes on: trunk/public/images/by-sa.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/public/images/by.png


(Binary files differ)
Property changes on: trunk/public/images/by.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/test/fixtures/license_attributes.yml (0 => 2230)


--- trunk/test/fixtures/license_attributes.yml	                        (rev 0)
+++ trunk/test/fixtures/license_attributes.yml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+  id: 1
+two:
+  id: 2

Added: trunk/test/fixtures/license_options.yml (0 => 2230)


--- trunk/test/fixtures/license_options.yml	                        (rev 0)
+++ trunk/test/fixtures/license_options.yml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+  id: 1
+two:
+  id: 2

Added: trunk/test/fixtures/licenses.yml (0 => 2230)


--- trunk/test/fixtures/licenses.yml	                        (rev 0)
+++ trunk/test/fixtures/licenses.yml	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,5 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+  id: 1
+two:
+  id: 2

Added: trunk/test/functional/license_attributes_controller_test.rb (0 => 2230)


--- trunk/test/functional/license_attributes_controller_test.rb	                        (rev 0)
+++ trunk/test/functional/license_attributes_controller_test.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'license_attributes_controller'
+
+# Re-raise errors caught by the controller.
+class LicenseAttributesController; def rescue_action(e) raise e end; end
+
+class LicenseAttributesControllerTest < Test::Unit::TestCase
+  def setup
+    @controller = LicenseAttributesController.new
+    @request    = ActionController::TestRequest.new
+    @response   = ActionController::TestResponse.new
+  end
+
+  # Replace this with your real tests.
+  def test_truth
+    assert true
+  end
+end

Added: trunk/test/functional/license_controller_test.rb (0 => 2230)


--- trunk/test/functional/license_controller_test.rb	                        (rev 0)
+++ trunk/test/functional/license_controller_test.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'license_controller'
+
+# Re-raise errors caught by the controller.
+class LicenseController; def rescue_action(e) raise e end; end
+
+class LicenseControllerTest < Test::Unit::TestCase
+  def setup
+    @controller = LicenseController.new
+    @request    = ActionController::TestRequest.new
+    @response   = ActionController::TestResponse.new
+  end
+
+  # Replace this with your real tests.
+  def test_truth
+    assert true
+  end
+end

Added: trunk/test/unit/license_attribute_test.rb (0 => 2230)


--- trunk/test/unit/license_attribute_test.rb	                        (rev 0)
+++ trunk/test/unit/license_attribute_test.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class LicenseAttributeTest < Test::Unit::TestCase
+  fixtures :license_attributes
+
+  # Replace this with your real tests.
+  def test_truth
+    assert true
+  end
+end

Added: trunk/test/unit/license_option_test.rb (0 => 2230)


--- trunk/test/unit/license_option_test.rb	                        (rev 0)
+++ trunk/test/unit/license_option_test.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class LicenseOptionTest < Test::Unit::TestCase
+  fixtures :license_options
+
+  # Replace this with your real tests.
+  def test_truth
+    assert true
+  end
+end

Added: trunk/test/unit/license_test.rb (0 => 2230)


--- trunk/test/unit/license_test.rb	                        (rev 0)
+++ trunk/test/unit/license_test.rb	2009-06-16 13:02:22 UTC (rev 2230)
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class LicenseTest < Test::Unit::TestCase
+  fixtures :licenses
+
+  # Replace this with your real tests.
+  def test_truth
+    assert true
+  end
+end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]