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
1
Merge Requests
1
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
Truong Ba Dieu
VenShop
Commits
93747a6e
Commit
93747a6e
authored
Jul 23, 2015
by
Truong Ba Dieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add meta for share
parent
8cb0cc71
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
12 deletions
+41
-12
app/controllers/products_controller.rb
+5
-0
app/helpers/application_helper.rb
+11
-0
app/services/solr_service.rb
+3
-3
app/views/layouts/share_social.html.erb
+15
-7
db/seeds.rb
+7
-2
No files found.
app/controllers/products_controller.rb
View file @
93747a6e
class
ProductsController
<
ApplicationController
include
ApplicationHelper
before_action
:get_categories
before_action
:authenticate_user!
,
:only
=>
[
:new
,
:create
]
after_action
:verify_authorized
,
:only
=>
[
:new
,
:create
]
...
...
@@ -9,6 +11,9 @@ class ProductsController < ApplicationController
@product
=
Product
.
find
(
params
[
:id
])
add_breadcrumb
@product
.
category
.
try
(
:name
),
category_path
(
@product
.
category
.
try
(
:id
))
add_breadcrumb
@product
.
title
fetch_social_info
(
@product
.
title
,
@product
.
title
,
@product
.
image
.
thumb
(
"158x158#"
).
url
)
render
layout:
"share_social"
end
def
new
...
...
app/helpers/application_helper.rb
View file @
93747a6e
module
ApplicationHelper
include
ActionView
::
Helpers
::
TextHelper
def
currency_number
(
price
=
0
,
currency
=
"usd"
)
"
#{
currency
}#{
price
}
"
end
...
...
@@ -7,4 +9,13 @@ module ApplicationHelper
Category
.
pluck
(
:name
,
:id
)
end
def
current_url
request
.
original_url
end
def
fetch_social_info
(
title
,
description
,
image
)
@title
=
"Venshop |
#{
truncate
(
title
,
length:
60
)
}
"
@description
=
truncate
(
description
,
length:
150
)
@image
=
"
#{
request
.
base_url
}#{
image
}
"
end
end
app/services/solr_service.rb
View file @
93747a6e
...
...
@@ -4,10 +4,10 @@ require 'rsolr'
class
SolrService
def
self
.
search
(
params
=
{})
params
[
:page
]
||=
1
params
[
:keyword
]
||=
""
params
[
:keyword
]
=
params
[
:keyword
]
.
gsub
(
"^"
,
""
).
gsub
(
":"
,
""
).
gsub
(
"("
,
""
).
gsub
(
")"
,
""
)
keyword
=
params
[
:keyword
]
||
""
keyword
=
keyword
.
gsub
(
"^"
,
""
).
gsub
(
":"
,
""
).
gsub
(
"("
,
""
).
gsub
(
")"
,
""
)
solr
=
RSolr
.
connect
:url
=>
ENV
[
"solr_url"
]
res
=
solr
.
paginate
params
[
:page
],
ENV
[
"default_perpage"
],
'select'
,
:params
=>
{
:q
=>
"*
#{
params
[
:keyword
]
}
*"
}
res
=
solr
.
paginate
params
[
:page
],
ENV
[
"default_perpage"
],
'select'
,
:params
=>
{
:q
=>
"*
#{
keyword
}
*"
}
res
[
"response"
][
"docs"
]
end
...
...
app/views/layouts/share_social.html.erb
View file @
93747a6e
...
...
@@ -11,17 +11,25 @@
<!-- Schema.org markup for Google+ -->
<meta
itemprop=
"name"
content=
"
<%=
@title
%>
"
>
<meta
itemprop=
"description"
content=
"
<%=
@description
%>
"
"
>
<meta
itemprop=
"image"
content=
"
<%=
@image
%>
"
"
>
<meta
itemprop=
"description"
content=
"
<%=
@description
%>
"
>
<meta
itemprop=
"image"
content=
"
<%=
@image
%>
"
>
<!-- Twitter Card data -->
<meta
name=
"twitter:card"
content=
"product"
>
<meta
name=
"twitter:site"
content=
"@venshop"
>
<meta
name=
"twitter:title"
content=
"
<%=
@title
%>
"
>
<meta
name=
"twitter:description"
content=
"
<%=
@description
%>
"
>
<meta
name=
"twitter:creator"
content=
"@venshop"
>
<meta
name=
"twitter:image"
content=
"
<%=
@image
%>
"
>
<!-- Open Graph data -->
<meta
property=
"og:title"
content=
"
Title Here
"
/>
<meta
property=
"og:title"
content=
"
<%=
@title
%>
"
/>
<meta
property=
"og:type"
content=
"article"
/>
<meta
property=
"og:url"
content=
"
http://www.example.com/
"
/>
<meta
property=
"og:image"
content=
"
http://example.com/image.jpg
"
/>
<meta
property=
"og:description"
content=
"
Description Here
"
/>
<meta
property=
"og:site_name"
content=
"
Site Name, i.e. Moz
"
/>
<meta
property=
"og:url"
content=
"
<%=
current_url
%>
"
/>
<meta
property=
"og:image"
content=
"
<%=
@image
%>
"
/>
<meta
property=
"og:description"
content=
"
<%=
@description
%>
"
/>
<meta
property=
"og:site_name"
content=
"
<%=
@title
%>
"
/>
<meta
property=
"article:published_time"
content=
"2013-09-17T05:59:00+01:00"
/>
<meta
property=
"article:modified_time"
content=
"2013-09-16T19:08:47+01:00"
/>
<meta
property=
"article:section"
content=
"Article Section"
/>
...
...
db/seeds.rb
View file @
93747a6e
...
...
@@ -7,4 +7,9 @@
# Mayor.create(name: 'Emanuel', city: cities.first)
User
.
create
(
name:
"admin"
,
email:
"admin@gmail.com"
,
password:
"abc123456"
)
if
User
.
find_by
(
email:
"admin@gmail.com"
).
blank?
\ No newline at end of file
u
=
User
.
find_by
(
email:
"admin@gmail.com"
)
if
u
.
blank?
u
=
User
.
create
(
name:
"admin"
,
email:
"admin@gmail.com"
,
password:
"abc123456"
)
end
u
.
role
=
User
.
roles
[
:admin
]
u
.
save
\ No newline at end of file
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