Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venshop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanvl
venshop
Commits
da8a08d5
Commit
da8a08d5
authored
Oct 23, 2013
by
vulehuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import product category from yahoo
parent
b6d0bbfe
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
1 deletions
+61
-1
venshop_app/app/models/product_category.rb
+2
-0
venshop_app/app/views/layouts/application.html.erb
+1
-0
venshop_app/app/views/layouts/application_one_col.html.erb
+1
-0
venshop_app/config/environment.rb
+4
-0
venshop_app/config/routes.rb
+1
-0
venshop_app/db/migrate/20131023083438_create_product_categories.rb
+11
-0
venshop_app/db/schema.rb
+9
-1
venshop_app/lib/tasks/sample_data.rake
+27
-0
venshop_app/spec/models/product_category_spec.rb
+5
-0
No files found.
venshop_app/app/models/product_category.rb
0 → 100644
View file @
da8a08d5
class
ProductCategory
<
ActiveRecord
::
Base
end
venshop_app/app/views/layouts/application.html.erb
View file @
da8a08d5
...
...
@@ -48,6 +48,7 @@
</div>
</div>
<%=
render
'layouts/footer'
%>
<%=
debug
(
params
)
if
Rails
.
env
.
development?
%>
<script
src=
"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
></script>
<script
src=
"//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"
></script>
<%=
javascript_include_tag
"application"
,
"data-turbolinks-track"
=>
true
%>
...
...
venshop_app/app/views/layouts/application_one_col.html.erb
View file @
da8a08d5
...
...
@@ -39,6 +39,7 @@
<%=
yield
%>
</div>
<%=
render
'layouts/footer'
%>
<%=
debug
(
params
)
if
Rails
.
env
.
development?
%>
<script
src=
"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
></script>
<script
src=
"//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"
></script>
<%=
javascript_include_tag
"application"
,
"data-turbolinks-track"
=>
true
%>
...
...
venshop_app/config/environment.rb
View file @
da8a08d5
...
...
@@ -8,3 +8,6 @@ RecaptchaMailhide.configure do |c|
c
.
private_key
=
'6LfDL-kSAAAAAFDLOFADJ0GJql1-6tCTo0PlWz7L'
c
.
public_key
=
'6LfDL-kSAAAAAG8JuwZhxLaT8X8iHZYpWu-7DAFe'
end
YAHOO_SHOPPING_DATA_APP_ID
=
'dj0zaiZpPXpIMzBsMUQyTk55dSZkPVlXazlZWGxzYjNoWU0yVW1jR285TUEtLSZzPWNvbnN1bWVyc2VjcmV0Jng9MzI-'
YAHOO_SHOPPING_DATA_SECRECT
=
'45b3584021d48d65984b515a2cd23623a3ec90cc'
\ No newline at end of file
venshop_app/config/routes.rb
View file @
da8a08d5
...
...
@@ -3,6 +3,7 @@ VenshopApp::Application.routes.draw do
resources
:sessions
,
only:
[
:new
,
:create
,
:destroy
]
get
"default_pages/home"
get
"users/new"
match
'/testyahoo'
,
to:
'users#testyahoo'
,
via:
'get'
match
'/signup'
,
to:
'users#new'
,
via:
'get'
match
'/signin'
,
to:
'sessions#new'
,
via:
'get'
match
'/signout'
,
to:
'sessions#destroy'
,
via:
'delete'
...
...
venshop_app/db/migrate/20131023083438_create_product_categories.rb
0 → 100644
View file @
da8a08d5
class
CreateProductCategories
<
ActiveRecord
::
Migration
def
change
create_table
:product_categories
do
|
t
|
t
.
string
:name
t
.
integer
:weight
t
.
boolean
:status
t
.
timestamps
end
end
end
venshop_app/db/schema.rb
View file @
da8a08d5
...
...
@@ -11,7 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20131023020942
)
do
ActiveRecord
::
Schema
.
define
(
version:
20131023083438
)
do
create_table
"product_categories"
,
force:
true
do
|
t
|
t
.
string
"name"
t
.
integer
"weight"
t
.
boolean
"status"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"users"
,
force:
true
do
|
t
|
t
.
string
"name"
...
...
venshop_app/lib/tasks/sample_data.rake
0 → 100644
View file @
da8a08d5
namespace
:db
do
desc
"Fill database with Yahoo shopping data"
task
populate: :environment
do
# Product Category
category_url
=
'http://dir.yahooapis.jp/Category/V1/Category'
category_path
=
'/Computers_and_Internet/Hardware/SmartPhone/'
request_url
=
category_url
+
'?appid='
+
YAHOO_SHOPPING_DATA_APP_ID
+
'&path='
+
category_path
require
'net/http'
require
'rexml/document'
# get the XML data as a string
xml_data
=
Net
::
HTTP
.
get_response
(
URI
.
parse
(
request_url
)).
body
# extract category information
doc
=
REXML
::
Document
.
new
(
xml_data
)
doc
.
elements
.
each
(
'CategoryResult/Category/Item'
)
do
|
ele
|
id
=
ele
.
elements
[
'Id'
].
text
title
=
ele
.
elements
[
'Title'
].
text
ProductCategory
.
create!
(
id:
id
,
name:
title
,
weight:
id
,
status:
true
)
end
end
end
\ No newline at end of file
venshop_app/spec/models/product_category_spec.rb
0 → 100644
View file @
da8a08d5
require
'spec_helper'
describe
ProductCategory
do
pending
"add some examples to (or delete)
#{
__FILE__
}
"
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment