initial crawl

This commit is contained in:
fanqiang 2014-03-29 10:57:36 +08:00
parent 404568be89
commit d935152ed7
27 changed files with 605 additions and 1 deletions

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -0,0 +1,96 @@
class OpenSourceProjectsController < ApplicationController
# GET /open_source_projects
# GET /open_source_projects.json
def index
per_page_option = 10
@open_source_projects = OpenSourceProject.all
@os_project_count = @open_source_projects.count
@os_project_pages = Paginator.new @os_project_count, per_page_option, params['page']
@open_source_projects = OpenSourceProject.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @open_source_projects }
end
end
# GET /open_source_projects/1
# GET /open_source_projects/1.json
def show
@open_source_project = OpenSourceProject.find(params[:id])
respond_to do |format|
format.html {
render :layout => "base_opensource_p"
}
format.json { render json: @open_source_project }
end
end
def search
end
# GET /open_source_projects/new
# GET /open_source_projects/new.json
def new
@open_source_project = OpenSourceProject.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @open_source_project }
end
end
# GET /open_source_projects/1/edit
def edit
@open_source_project = OpenSourceProject.find(params[:id])
end
# POST /open_source_projects
# POST /open_source_projects.json
def create
@open_source_project = OpenSourceProject.new(params[:open_source_project])
respond_to do |format|
if @open_source_project.save
format.html { redirect_to @open_source_project, notice: 'Open source project was successfully created.' }
format.json { render json: @open_source_project, status: :created, location: @open_source_project }
else
format.html { render action: "new" }
format.json { render json: @open_source_project.errors, status: :unprocessable_entity }
end
end
end
# PUT /open_source_projects/1
# PUT /open_source_projects/1.json
def update
@open_source_project = OpenSourceProject.find(params[:id])
respond_to do |format|
if @open_source_project.update_attributes(params[:open_source_project])
format.html { redirect_to @open_source_project, notice: 'Open source project was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @open_source_project.errors, status: :unprocessable_entity }
end
end
end
# DELETE /open_source_projects/1
# DELETE /open_source_projects/1.json
def destroy
@open_source_project = OpenSourceProject.find(params[:id])
@open_source_project.destroy
respond_to do |format|
format.html { redirect_to open_source_projects_url }
format.json { head :no_content }
end
end
end

View File

@ -0,0 +1,14 @@
module OpenSourceProjectsHelper
def render_opensource_project(os_projects)
s=''
s << "<ul class='projects'>\n"
os_projects.each do |project|
s << "<li class='project-table'><div class='#{classes}'>"
s << "div class='root'"
s << "</div>\n"
s << "</li>\n"
end
s << "</ul>"
end
end

View File

@ -0,0 +1,6 @@
class OpenSourceProject < ActiveRecord::Base
attr_accessible :String
def short_description(length = 255)
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
end
end

View File

@ -0,0 +1,130 @@
<% @nav_dispaly_project_label = 1 %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
</head>
<!--add by huang-->
<body class="<%= h body_css_classes %>">
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
<%= render :partial => 'layouts/base_header'%>
<div id="main">
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px; color: #15bccf">软件项目托管社区</td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px">
<div class="top-content-search">
<%= form_tag(:controller => 'projects', :action => "search", :method => :get) do %>
<%= text_field_tag 'name', params[:name], :size => 20 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %>
</div></td>
</tr>
<tr></tr>
</table>
</div>
<div id="sidebar">
<div class="spaceleft">
<div class="inf_user_image">
<% @open_source_project = OpenSourceProject.find(params[:id])%>
<table>
<tr>
<td>图片</td>
<td>
<div class="info-course">
<%= @open_source_project.name %>
</div><div>
</div><div style="margin-left: 20px;">
</div></td>
</tr>
</table>
</div>
<div class="user_fans">
<table width="240" border="0">
<tr align="center" width="80px">
<td class="font_index"><%= 0 %></td>
<td class="font_index"><%= @open_source_project.users_count %></td>
<td class="font_index"><%= 0 %></td>
</tr>
<tr class="font_aram">
<td align="center" width="70px"> <%= l(:label_member) %></td>
<td align="center" width="100px"><%= l(:label_user_watchered) %></td>
<td align="center" width="70px"> <%= l(:label_project_issues) %></td>
<!-- <td align="center" width="58px"><%= l(:label_attachment) %></td> -->
</tr>
</table>
<div class="user_underline"></div>
</div>
<div class="inf_user_context">
<div class="font_title_left">
<%= l(:label_project_overview) %>
</div>
<div style="padding-bottom: 8px">
<div class="font_lighter_sidebar">
<%= textilizable @open_source_project.description %>
</div>
<div class="created_on_project">
<strong style="color: #15bccf"><%= l(:label_create_time) %></strong><%= format_time(@open_source_project.created_at) %>
</div>
</div>
<div class="user_underline"></div>
</div>
<!--tags-->
<div class="user_fans">
<!-- added by william -for tag -->
<!-- tag -->
</div>
<!--tool-->
<div class="user_underline"></div>
</div>
</div>
<div id="content">
<div class="tabs_new">
</div>
<%= render_flash_messages %>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
</div>
<%= render :partial => 'layouts/base_footer'%>
</div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<div id="ajax-modal" style="display:none;"></div>
</div>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</div>
</body>
</html>

View File

@ -0,0 +1,21 @@
<%= form_for(@open_source_project) do |f| %>
<% if @open_source_project.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@open_source_project.errors.count, "error") %> prohibited this open_source_project from being saved:</h2>
<ul>
<% @open_source_project.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :String %><br />
<%= f.text_field :String %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -0,0 +1,56 @@
<!--Added by nie-->
<div class="project-block">
<div class="img-tag">
图片
</div>
<div class="wiki-description">
<p>
<%= textilizable(project.short_description, :project => project) %>
</p>
</div>
<div class="information">
<p class="stats">
<strong><span style="font-size: 17px;margin-left: 145px">
<%= 1%></span></strong>
<%= content_tag('span', l(:label_x_follow_people,:count =>0)) %>
</p>
<p class="stats">
<strong><span style="font-size: 17px;margin-left: 145px">
<%= 1%></span></strong>
<%= content_tag('span', l(:label_x_current_contributors, :count => 0)) %>
</p>
<p class="stats">
<strong><span style="font-size: 17px;margin-left: 145px">
<%= 1 %></span></strong>
<%= content_tag('span', l(:label_since_last_commits)) %>
</p>
<p class="stats">
<strong><span style="font-size: 17px;margin-left: 145px">
<%= 1 %></span></strong>
<%= content_tag('span', l(:label_commit_on)) %>
</p>
</div>
</div>
<div class="add-info">
<div class="main-language">
<%= content_tag('span', "#{l(:default_role_manager)}: ") %>
</div>
<div class="licences">
<%= content_tag('span', "#{l(:label_create_time)}: ") %><%= content_tag('span', format_time(project.created_at)) %>
</div>
</div>
<div class="tags">
<!-- added by william -for tag -->
<div id="tags">
<%= image_tag( "/images/sidebar/tags.png") %>
</div>
</div>

View File

@ -0,0 +1,6 @@
<h1>Editing open_source_project</h1>
<%= render 'form' %>
<%= link_to 'Show', @open_source_project %> |
<%= link_to 'Back', open_source_projects_path %>

View File

@ -0,0 +1,45 @@
<div class="top-content">
<%= form_tag(:controller => 'open_source_projects', :action => "search", :method => :get) do %>
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_project_deposit) %></td>
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
<td rowspan="2"></td>
<td rowspan="2" >
<div class="project-search" style="float: right">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
</div></td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> </a></td>
<td ><%= link_to l(:field_homepage), home_path %> > <%= link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %></td>
</tr>
</table>
<% end %>
</div>
<div id="projects-index">
<ul class='projects'>
<% @open_source_projects.each do |project| %>
<li class='project-table'>
<div class = 'root'>
<%= link_to project.name, open_source_projects_path(project), :class=>"project root leaf"%>
<span style="float: right;"></span>
<%= render :partial => 'open_source_projects/os_project', :locals => {:project => project}%>
</div>
</li>
<% end %>
</ul>
</div>
<div class="pagination">
<ul>
<%= pagination_links_full @os_project_pages, @os_project_count %>
</ul>
</div>
<% html_title(l(:label_project_plural)) -%>

View File

@ -0,0 +1,5 @@
<h1>New open_source_project</h1>
<%= render 'form' %>
<%= link_to 'Back', open_source_projects_path %>

View File

@ -0,0 +1,10 @@
<p id="notice"><%= notice %></p>
<p>
<b>String:</b>
<%= @open_source_project.name %>
</p>
<%= link_to 'Edit', edit_open_source_project_path(@open_source_project) %> |
<%= link_to 'Back', open_source_projects_path %>

View File

@ -16,6 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RedmineApp::Application.routes.draw do
resources :open_source_projects do
collection do
match 'search', via: [:get, :post]
end
end
match 'course', :to => 'welcome#course', :via => :get
resources :stores do
collection do

View File

@ -0,0 +1,15 @@
class CreateOpenSourceProjects < ActiveRecord::Migration
def change
create_table :open_source_projects do |t|
t.column "name", :string, :default => nil, :null => true
t.column "description", :string, :default => '', :null => true
t.column "commit_count", :integer, :default => 0
t.column "code_line", :integer, :default => 0
t.column "users_count",:integer, :default => 0
t.column "last_commit_time", :date, :null => true
t.column "url", :string, :default => nil, :null => true
t.column "date_collected", :date, :null => true
t.timestamps
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140319092720) do
ActiveRecord::Schema.define(:version => 20140324015819) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -493,6 +493,19 @@ ActiveRecord::Schema.define(:version => 20140319092720) do
t.string "salt", :null => false
end
create_table "open_source_projects", :force => true do |t|
t.string "name"
t.string "description", :default => ""
t.integer "commit_count", :default => 0
t.integer "code_line", :default => 0
t.integer "users_count", :default => 0
t.date "last_commit_time"
t.string "url"
t.date "date_collected"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "praise_tread_caches", :force => true do |t|
t.integer "object_id", :null => false
t.string "object_type"

11
test/fixtures/activities.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
act_id:
act_type: MyString
user_id:
two:
act_id:
act_type: MyString
user_id:

11
test/fixtures/forums.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

11
test/fixtures/journal_replies.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
journal_id: 1
user_id: 1
reply_id: 1
two:
journal_id: 1
user_id: 1
reply_id: 1

View File

@ -0,0 +1,7 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
String:
two:
String:

View File

@ -0,0 +1,49 @@
require 'test_helper'
class ForumsControllerTest < ActionController::TestCase
setup do
@forum = forums(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:forums)
end
test "should get new" do
get :new
assert_response :success
end
test "should create forum" do
assert_difference('Forum.count') do
post :create, forum: { }
end
assert_redirected_to forum_path(assigns(:forum))
end
test "should show forum" do
get :show, id: @forum
assert_response :success
end
test "should get edit" do
get :edit, id: @forum
assert_response :success
end
test "should update forum" do
put :update, id: @forum, forum: { }
assert_redirected_to forum_path(assigns(:forum))
end
test "should destroy forum" do
assert_difference('Forum.count', -1) do
delete :destroy, id: @forum
end
assert_redirected_to forums_path
end
end

View File

@ -0,0 +1,49 @@
require 'test_helper'
class OpenSourceProjectsControllerTest < ActionController::TestCase
setup do
@open_source_project = open_source_projects(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:open_source_projects)
end
test "should get new" do
get :new
assert_response :success
end
test "should create open_source_project" do
assert_difference('OpenSourceProject.count') do
post :create, open_source_project: { String: @open_source_project.String }
end
assert_redirected_to open_source_project_path(assigns(:open_source_project))
end
test "should show open_source_project" do
get :show, id: @open_source_project
assert_response :success
end
test "should get edit" do
get :edit, id: @open_source_project
assert_response :success
end
test "should update open_source_project" do
put :update, id: @open_source_project, open_source_project: { String: @open_source_project.String }
assert_redirected_to open_source_project_path(assigns(:open_source_project))
end
test "should destroy open_source_project" do
assert_difference('OpenSourceProject.count', -1) do
delete :destroy, id: @open_source_project
end
assert_redirected_to open_source_projects_path
end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class ActivityTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

7
test/unit/forum_test.rb Normal file
View File

@ -0,0 +1,7 @@
require 'test_helper'
class ForumTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class ForumsHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class OpenSourceProjectsHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class JournalReplyTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class OpenSourceProjectTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end