module OpenSourceProjectsHelper
  def show_condition(app_dir, language, created_at, name)
    s=''.html_safe
    unless app_dir.nil?
      s_temp = content_tag('a', app_dir)
      temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :language => language, :created_at => created_at, :name => name}
      temp = content_tag('span', temp, :class => 'del')
      s_temp << temp
      s_temp = content_tag('span', s_temp, :class => 'tag_show')
      s << content_tag('div', s_temp, :id => 'tag')

    end
    unless language.nil?
      s_temp = content_tag('a', language)
      temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :app_dir => app_dir, :created_at => created_at, :name => name}
      temp = content_tag('span', temp, :class => 'del')
      s_temp << temp
      s_temp = content_tag('span', s_temp, :class => 'tag_show')
      s << content_tag('div', s_temp, :id => 'tag')
    end
    unless created_at.nil?
      s_temp = content_tag('a', created_at)
      temp = link_to 'x', {:controller => "open_source_projects", :action => "remove_condition", :app_dir => app_dir, :language => language, :name => name}
      temp = content_tag('span', temp, :class => 'del')
      s_temp << temp
      s_temp = content_tag('span', s_temp, :class => 'tag_show')
      s << content_tag('div', s_temp, :id => 'tag')
    end
    s = content_tag('div', s, :id => 'tags_show')
    s = content_tag('div', s, :id => 'tags')
    s = content_tag('div', s, :class => 'user_tags')
  end

  def get_open_source_projects_by_tag(tag_name)
    OpenSourceProject.tagged_with(tag_name).order('created_at desc')
  end
  
  def show_origin(url)
    
  end
  
  def show_description(bug, open_source_project)
    description = BugToOsp.where("osp_id = ? and relative_memo_id = ?", open_source_project.id, bug.id).first.description
    if description.nil? || description == ''
      description = open_source_project.name + l(:label_bug)
    end
    description
  end
  
  def show_description_of_bug(bug)
    description = bug.description
    if description.nil? || description == ''
      description = bug.open_source_project.name + l(:label_bug)
    end
    description
  end
end
