Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

2008/08/22

Rails 2.1 OSX Finder like ColumnNav.

original google code : http://columnav.googlecode.com/svn/trunk/index.html

Update(22/8/2008):
Since ResponseHeader was "applicatoin/json ;utf8 ",
The original code does not work.

in columnav.js,
Before:
var contentType = o.getResponseHeader['Content-Type'];
if ('application/json' == contentType.replace(/\s+$/,'')) {

After:
var contentType = o.getResponseHeader['Content-Type'];
var compareString = contentType.replace(/\s+$/,'')
if (compareString.include('application/json')) {



It was not easy to implement "finder" with extjs. And furthermore, my codes were getting ugly. Almost hard to see. So I abandoned Extjs on the user-view. I've decided to use it on admin pages.



ColumNav is a hierarchical menu implementation utilizing Bill Scott's Yahoo UI Carousel component. Content is loaded from an unordered list and displayed in a scrollable viewport, similar to Column View in the Mac OS X Finder.


Features include:


  • infinite extensibility using Ajax to build sub-menus
  • instantiation from DOM or JSON data sources
  • a highly customizable look and feel using CSS
  • support for multiple columns
  • support for keyboard-only navigation (CTRL + arrow keys)
  • cross-browser compatibility

App/views/Categories/index.html



<% content_for :head do%>


<%= stylesheet_link_tag 'cssbits_notice' %>
<%= stylesheet_link_tag 'columnav', 'columnav_apply' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag "columnav/yui/yahoo-min" %>
<%= javascript_include_tag "columnav/yui/utilities" %>
<%= javascript_include_tag "columnav/yui/container_core-min" %>

<%= javascript_include_tag "columnav/carousel_min" %>
<%= javascript_include_tag "columnav/columnav" %>
<%= javascript_include_tag "columnav/columnav_json_parsing" %>


<% javascript_tag do %>
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}


function init() {
var cn_cfg = {
numVisible: 3,
prevElement: 'columnav-prev',
datasource: '/categories/columntree/1.json'
};
var cn = new YAHOO.extension.ColumNav('columnav', cn_cfg);
}
YAHOO.util.Event.addListener(window, 'load', init);
<% end %>

<% end %>







App/controllers/Categories_controller.rb



def columntree(id = params[:id])
categories = Category.find_all_by_parent_id(id)

data = get_tree(categories, id)
respond_to do |format|
format.json { render :text => data[0].to_json, :layout => false }
end
end


def get_tree(categories, parent_id)
parent = Category.find_by_id(parent_id)
data = Array.new
data.concat([ "ul" => insert(categories, parent) ])
return data
end

def insert(categories, parent)
result = Array.new
result.concat(["li" => insert_data(categories, parent) ])
return result[0]
end

def insert_data(categories, parent)
iterated = Array.new
categories.each { |category|
if !category.leaf?
iterated.concat(["a" => {"#text" => category.text, "@href" => "/categories/columntree/"+category.id.to_s+".json", "@rel" => "ajax"}, "id" => category.id]) # "@rel" => "ajax" 면 폴더로 인식.
else
iterated.concat(["a" => {"#text" => category.text, "@href" => "http://peepcode.com"}, "id" => category.id])
end
}
return iterated
end



app/models/category.rb


class Category < dependent =""> :nullify
has_many :portfolios, :dependent => :nullify

acts_as_nested_set

validates_presence_of :text

has_attached_file :photo,
:styles => { :medium => "220x180#", :thumb => "100x82#" },
:path => "#{RAILS_ROOT}/public/images/category_photos/:id/:style_:basename.:extension",
:url => "/images/category_photos/:id/:style_:basename.:extension",
:default_url => "/images/category_photos/missing.png",
:whiny_thumbnails => true


#liquid
liquid_methods :text

# extjs를 위한 코드임

def self.root_nodes
find(:all, :conditions => 'parent_id IS NULL')
end

def self.find_children(start_id = nil)
start_id.to_i == 0 ? root_nodes : find(start_id).direct_children
end

def children
Category.find_all_by_parent_id(self.id)
end

def self.find_level1
find_all_by_parent_id(1)
end

def leaf
unknown? || children_count == 0
end

def leaf?
unknown? || children_count == 0
end


def to_json_with_leaf(options = {})
self.to_json_without_leaf(options.merge(:methods => :leaf))
end
alias_method_chain :to_json, :leaf
private
end

2007/02/12

Apple "Pile"

United States Patent Application 20070033537
Kind Code A1
Mander; Richard ; et al. February 8, 2007

Method and apparatus for organizing information in a computer system

Abstract

A method and apparatus for organizing information in a computer filing system. The method and apparatus include the creation of a pile comprising a collection of documents and displaying a graphical representation of the collection of documents. The method and apparatus further include browsing the collection of documents by pointing a cursor at a particular item in the collection of documents to reveal an indicia for the particular item in the collection of documents. The filing system can automatically divide a pile (e.g. a collection of documents from an electronic mail network) into subpiles on the basis of the content of each document in the pile, and the filing system, at the users request can automatically file away documents into existing piles in the computer system on the basis of a similarity match between the content (or other internal representation) of the document and the content (or other internal representation) of existing piles in the computer system. The filing system can also create a pile from a sample document by using the internal representation of the document as the internal representation of the new pile. The computer filing system provides various interfaces in connection with piles to the user of the system to provide feedback and other information to the user, including information concerning the documents and piles in the computer's filing system.


Inventors: Mander; Richard; (Palo Alto, CA) ; Rose; Daniel E.; (San Jose, CA) ; Salomon; Gitta; (Palo Alto, CA) ; Wong; Yin Yin; (Menlo Park, CA) ; Oren; Timothy; (Sunnyvale, CA) ; Booker; Susan; (San Carlos, CA) ; Houde; Stephanie; (Cambridge, MA)
Correspondence Name and Address:
    BLAKELY SOKOLOFF TAYLOR & ZAFMAN
12400 WILSHIRE BOULEVARD
SEVENTH FLOOR
LOS ANGELES
CA
90025-1030
US
Serial No.: 497460
Series Code: 11
Filed: July 31, 2006

U.S. Current Class: 715/764; 707/100; 715/810
U.S. Class at Publication: 715/764; 715/810; 707/100
Intern'l Class: G06F 3/00 20060101 G06F003/00; G06F 17/00 20060101 G06F017/00; G06F 7/00 20060101 G06F007/00


2006/11/01

ruby on rails


PHP, ASP, JSP, RUBY

Well, ruby is not that popular though, I'm planning to digg it further. There're only one ruby-on-rails hosting site in Korea. So I paid them for my school web project. For now, we didn't make any significant progress. Still working on it. But the codes of ruby is so beautiful that I just can't resist to use and learn it. May be that could be one reason that ruby manias are after it. The address of our site is http://jaigouk.koruby.com/prisonbreak/public . In the future user applications would be based on web. Without learning web technologies like ajax, it would be hard to survive as a programmer. There're already plenty of API mesh-up sites(http://www.programmableweb.com/matrix). Now it's time to ignite your ideas.

2006/09/15

Web programming class - project team logo






I'm attending a web programming class which need a project team. Team name is "Prison Break", I made a web2.0 style logo via http://msig.info/web2.php. This site automaticaly generate Flickr style logos. I thought this solution is just appropriate for us.

I requested a free web hosting at http://www.freeonrails.com/. Still waiting the administrator's answer. I'm plannig to use Ruby on Rails as our web server framework. Here is the message that I posted.

================================================

Hello. I'm a student majoring in computer science in Korea.My friends and I are studying Ruby on Rails and ajax. By googling I found freeonrails, and registered without hesitating. For now we want to make a project site. In class, we are practicing javascript. It wan't easy to find a hosting site which give little sapce with Ruby on Rails capability in Korea. I'm 28 years old, and interested in Web2, Long Tail theory. I think there still are posibilities to start a biz through web. Ideas are flowing everywhere, and changes are too fast to catch. Agile development with Ruby on Rails would help at this point. I'm looking forward your permission.Thank you.