[25857] users/jberry/mpwa

source_changes at macosforge.org source_changes at macosforge.org
Sun Jun 3 13:20:10 PDT 2007


Revision: 25857
          http://trac.macosforge.org/projects/macports/changeset/25857
Author:   jberry at macports.org
Date:     2007-06-03 13:20:09 -0700 (Sun, 03 Jun 2007)

Log Message:
-----------
mpwa: add ui and structural support for tagging of ports and portpkgs.

Modified Paths:
--------------
    users/jberry/mpwa/app/controllers/port_controller.rb
    users/jberry/mpwa/app/controllers/port_pkg_controller.rb
    users/jberry/mpwa/app/models/port.rb
    users/jberry/mpwa/app/views/port/show.rhtml
    users/jberry/mpwa/app/views/port_pkg/show.rhtml
    users/jberry/mpwa/app/views/tag/show.rhtml
    users/jberry/mpwa/doc/TODO.txt
    users/jberry/mpwa/public/stylesheets/main.css

Modified: users/jberry/mpwa/app/controllers/port_controller.rb
===================================================================
--- users/jberry/mpwa/app/controllers/port_controller.rb	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/app/controllers/port_controller.rb	2007-06-03 20:20:09 UTC (rev 25857)
@@ -61,6 +61,18 @@
       :conditions => Port.build_query_conditions(@q)
   end
   
+  def tag
+    port = Port.find(params[:id])
+    params[:tags].split(/,?[ ]+/).each do |t|
+      if t =~ /\-(.*)/
+        port.remove_tag($1) if $1
+      elsif t =~ /\+?(.+)/
+        port.add_tag($1)
+      end
+    end
+    redirect_to :action => 'show', :id => port
+   end
+  
   private :create, :edit, :update, :destroy
   
 end

Modified: users/jberry/mpwa/app/controllers/port_pkg_controller.rb
===================================================================
--- users/jberry/mpwa/app/controllers/port_pkg_controller.rb	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/app/controllers/port_pkg_controller.rb	2007-06-03 20:20:09 UTC (rev 25857)
@@ -85,5 +85,17 @@
         :id => port_pkg.file_ref_by_path(params[:path].join, '/')
   end
   
+  def tag
+    port_pkg = PortPkg.find(params[:id])
+    params[:tags].split(/,?[ ]+/).each do |t|
+      if t =~ /\-(.*)/
+        port_pkg.remove_tag($1) if $1
+      elsif t =~ /\+?(.+)/
+        port_pkg.add_tag($1)
+      end
+    end
+    redirect_to :action => 'show', :id => port_pkg
+   end
+  
   private :create, :edit, :update, :destroy
 end

Modified: users/jberry/mpwa/app/models/port.rb
===================================================================
--- users/jberry/mpwa/app/models/port.rb	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/app/models/port.rb	2007-06-03 20:20:09 UTC (rev 25857)
@@ -43,6 +43,10 @@
         self.tags << Tag.find_or_create_by_name(name) unless has_tag name
     end
     
+    def remove_tag(name)
+        self.tags.select { |t| t.name == name }.each { |t| self.tags.delete(t) }
+    end
+    
     def <=>(other)
         self.name <=> other.name
     end

Modified: users/jberry/mpwa/app/views/port/show.rhtml
===================================================================
--- users/jberry/mpwa/app/views/port/show.rhtml	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/app/views/port/show.rhtml	2007-06-03 20:20:09 UTC (rev 25857)
@@ -2,6 +2,23 @@
 
 <h2><%=h @port.name %></h2>
 
+<div class='tagbox'>
+  <h4>Tags</h4>
+  
+  <form action='/port/tag' method='post'>
+    <input type='hidden' name='id' value='<%=h @port.id %>'>
+    <p><input type='text' size='20' name='tags'></input>
+      <input type='submit' name='add_tags' value='Add'></input>
+      </p>
+  </form>
+  
+  <p>
+    <% for tag in @port.tags.sort %>
+  		<%= link_to tag.name, :controller => 'tag', :action => 'show', :id => tag %><br />
+  	<% end %>
+	</p>
+</div>
+
 <p class='short_desc'><%=h @port.short_desc if @port.short_desc %></p>
 <% if @port.long_desc && @port.long_desc != @port.short_desc %>
     <div class='long_desc'><%= simple_format(@port.long_desc) %></div>
@@ -16,13 +33,6 @@
 	<% end %>
 </p>
 
-<p>
-  <strong>Tags:</strong>
-	<% for tag in @port.tags.sort %>
-		<%= link_to tag.name, :controller => 'tag', :action => 'show', :id => tag %>
-	<% end %>
-</p>
-
 <h4>Port Packages</h4>
 <table>
 	<tr>

Modified: users/jberry/mpwa/app/views/port_pkg/show.rhtml
===================================================================
--- users/jberry/mpwa/app/views/port_pkg/show.rhtml	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/app/views/port_pkg/show.rhtml	2007-06-03 20:20:09 UTC (rev 25857)
@@ -1,7 +1,24 @@
 <% @page_title = "portpkg #{@port_pkg.id} for #{@port_pkg.port.name}" %>
 
-<h3>PortPkg <%= @port_pkg.id %></h3>
+<h2>PortPkg <%= @port_pkg.id %></h2>
 
+<div class='tagbox'>
+  <h4>Tags</h4>
+  
+  <form action='/port_pkg/tag' method='post'>
+    <input type='hidden' name='id' value='<%=h @port_pkg.id %>'>
+    <p><input type='text' size='20' name='tags'></input>
+      <input type='submit' name='add_tags' value='Add'></input>
+      </p>
+  </form>
+  
+  <p>
+    <% for tag in @port_pkg.tags.sort %>
+  		<%= link_to tag.name, :controller => 'tag', :action => 'show', :id => tag %><br />
+  	<% end %>
+	</p>
+</div>
+
 <p><strong>Port:</strong>
     <%= link_to @port_pkg.port.name,
                 :controller => 'port', :action => 'show',
@@ -46,13 +63,6 @@
 	<% end %>
 </p>
 
-<p>
-  <strong>Tags:</strong>
-	<% for tag in @port_pkg.tags.sort %>
-		<%= link_to tag.name, :controller => 'tag', :action => 'show', :id => tag %>
-	<% end %>
-</p>
-
 <h4>Files:</h4>
 <table>
   <tr>

Modified: users/jberry/mpwa/app/views/tag/show.rhtml
===================================================================
--- users/jberry/mpwa/app/views/tag/show.rhtml	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/app/views/tag/show.rhtml	2007-06-03 20:20:09 UTC (rev 25857)
@@ -13,15 +13,13 @@
 	<% end %>
 </table>
 
-<!--
 <h4>Port Packages with this tag</h4>
 <table>
 	<% for row in columnize(@tag.port_pkgs, 16) %>
 		<tr>
 			<% for pkg in row %>
-				<td><%= link_to pkg.id, :controller => 'port_pkg', :action => 'show', :id => pkg if pkg %></td>
+				<td><%= link_to "#{pkg.name} #{pkg.id}", :controller => 'port_pkg', :action => 'show', :id => pkg if pkg %></td>
 			<% end %>
 		</tr>
 	<% end %>
 </table>
--->

Modified: users/jberry/mpwa/doc/TODO.txt
===================================================================
--- users/jberry/mpwa/doc/TODO.txt	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/doc/TODO.txt	2007-06-03 20:20:09 UTC (rev 25857)
@@ -7,6 +7,8 @@
     - Portname vs. partial portname? (Currently searches partial portname).
     - Search port descriptions in addition to port names.
     
+  - fix port_pkg name booboo: update port_pkgs pkg join ports port on port_id=port.id set pkg.name=port.name;
+    
 Needed Schema Changes:
 
 UI Design Thoughts:

Modified: users/jberry/mpwa/public/stylesheets/main.css
===================================================================
--- users/jberry/mpwa/public/stylesheets/main.css	2007-06-03 20:19:17 UTC (rev 25856)
+++ users/jberry/mpwa/public/stylesheets/main.css	2007-06-03 20:20:09 UTC (rev 25857)
@@ -9,8 +9,7 @@
 }
 
 .header_right {
-    width: 40%;
-    float: left;
+    float: right;
 }
 
 .mp_body {
@@ -18,6 +17,15 @@
     width: 100%;
 }
 
+/* General */
+
+.tagbox {
+  float: right;
+  width: 200px;
+  padding: 6px;
+  border: 1px solid;
+}
+
 /* Port */
 .short_desc {
   font-style: italic;
@@ -25,4 +33,5 @@
 
 .long_desc {
   max-width: 600px;
-}
\ No newline at end of file
+}
+

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070603/ab63c8da/attachment.html


More information about the macports-changes mailing list