Skip to content

Commit 7895c43

Browse files
author
hatter
committed
after some theming work + slugs random
1 parent 0a9fe9b commit 7895c43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+477
-86
lines changed

app/assets/javascripts/application.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@
2525
//= require ckeditor/init
2626

2727

28-
//= require_tree .
28+
//= require_tree .
29+
30+
31+
32+
33+
// initialize bootstrap tooltips
34+
$(function () {
35+
$("[data-toggle='tooltip']").tooltip();
36+
});
+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
# Place all the behaviors and hooks related to the matching controller here.
22
# All this logic will automatically be available in application.js.
33
# You can use CoffeeScript in this file: http://coffeescript.org/
4+
5+
6+
# $(document).ready ->
7+
# $(".modal").on("ajax:success", (e, data, status, xhr) ->
8+
# $('.modal').modal('hide')
9+
# ).on "ajax:error", (e, xhr, status, error) ->
10+
# $("body").append "<p>ERROR</p>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.login_corner {
2+
width: 20px;
3+
height: 20px;
4+
position: absolute;
5+
top: 0px;
6+
right: 0px;
7+
z-index: 800;
8+
}

app/assets/stylesheets/theme_white.css.scss

+87-13
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,48 @@
88
border-radius: 5px;
99
}
1010

11+
html {
12+
min-height: 100%;
13+
position: relative;
14+
}
15+
16+
body {
17+
font-size: 16px;
18+
padding-bottom: 60px;
19+
}
20+
1121

22+
.line_div_2px {
23+
width: 100%;
24+
height: 2px;
25+
background: #F2F2F2;
26+
}
27+
28+
.btn.gl_indent .glyphicon,
29+
a.gl_indent .glyphicon {
30+
padding: 0 6px 0 0px;
31+
}
1232

1333
// ==================== Hedader ====================
1434

1535
.header {
16-
margin: 20px 0px;
36+
margin: 20px 0px 0px 0px;
1737
padding-bottom: 20px;
18-
border-bottom: 2px solid #E5E5E5;
38+
// border-bottom: 2px solid #E5E5E5;
1939
}
2040

2141

42+
// ==================== config_cog ====================
43+
44+
.config_cog {
45+
position: absolute;
46+
right: 0px; top: -10px;
47+
display: none;
48+
}
49+
50+
div:hover > .config_cog{
51+
display: block;
52+
}
2253
// ==================== Logo ====================
2354

2455

@@ -31,11 +62,6 @@
3162
display: none;
3263
}
3364
}
34-
.logo_container:hover {
35-
.config_cog {
36-
display: block;
37-
}
38-
}
3965

4066

4167
// ==================== home_button ====================
@@ -52,9 +78,14 @@
5278
position: absolute;
5379
top: 50%; right: 0px;
5480
height: 30px;
55-
margin-top: -35px;
81+
margin-top: -15px;
5682
}
5783

84+
// .header_menu {
85+
// position: absolute;
86+
// bottom: 10px; right: 0px;
87+
// }
88+
5889

5990
.menu_links{
6091
position: relative;
@@ -101,10 +132,13 @@
101132
font-size: 20px;
102133
float: left;
103134
}
104-
.btn {
105135

136+
span.badge {
137+
margin: 7px 0 0 10px;
106138
}
107139

140+
141+
108142
.catalog_categoryes_container {
109143
float: none;
110144
clear: both;
@@ -126,11 +160,22 @@
126160

127161
}
128162

129-
163+
// =============================================================
164+
// big_image
165+
// =============================================================
166+
.big_image {
167+
position: relative;
168+
img {
169+
width: 100%;
170+
}
171+
}
130172

131173
// ==================== page ====================
132174

133175
.page_container {
176+
177+
margin: 0 0 40px 0;
178+
134179
.edit_page_button {
135180
display: none;
136181

@@ -168,8 +213,37 @@
168213
}
169214

170215

216+
.field_with_errors {
217+
@extend .has-error;
218+
}
219+
220+
221+
222+
// =============================================================
223+
// img_catalog
224+
// =============================================================
225+
226+
.img_catalog {
227+
margin: 40px 0 40px 0;
228+
229+
h1 {
230+
margin-bottom: 20px;
231+
}
232+
}
233+
234+
235+
236+
// =============================================================
237+
// #footer
238+
// =============================================================
239+
240+
#footer {
241+
padding: 20px 0 0 0;
242+
position: absolute;
243+
height: 60px;
244+
width: 100%;
245+
background-color: #F5F5F5;
246+
bottom: 0;
247+
}
171248

172249

173-
.field_with_errors {
174-
@extend .has-error
175-
}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.top_bar_container {
2+
background: #999;
3+
.logo {
4+
margin: 12px 0 0 5px;
5+
}
6+
7+
ul {
8+
margin: 0;
9+
background: url('/other_img/gradient_border.png') right repeat-y;
10+
li {
11+
float: left;
12+
list-style: none;
13+
}
14+
}
15+
16+
17+
a {
18+
display: block;
19+
text-decoration: none;
20+
text-transform: lowercase;
21+
float: left;
22+
color: #fff;
23+
padding: 20px 20px;
24+
background: url('/other_img/gradient_border.png') left repeat-y;
25+
}
26+
a:hover {
27+
background: #666;
28+
}
29+
}

app/controllers/application_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
99
# request.host != 'r-code-main.com' && request.domain != 'lvh.me'
1010

1111
def current_site
12-
if request.domain == 'snowboarding.by'#'snowboarding.by' #|| request.domain = 'lvh.me'
12+
if request.domain == 'r-code-main.com'#'snowboarding.by' #|| request.domain = 'lvh.me'
1313
if request.subdomain.present?
1414
@site = Site.where('sub_domain = ?', request.subdomain.sub(/^www./,'')).first!
1515
else

app/controllers/catalogs_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def create
1919
respond_to do |format|
2020
if @catalog.save
2121
@menu_item = MenuItem.create(link: catalog_url(@catalog), catalog_id: @catalog.id, menu_id: @catalog.menu_id, title: @catalog.title)
22-
format.html { redirect_to catalog_url(@catalog), notice: 'Catalog was successfully created.' }
22+
format.html { redirect_to menu_url(@catalog.menu), notice: 'Catalog was successfully created.' }
2323
else
2424
flash[:error] = "there was a problem"
2525
end
@@ -35,7 +35,7 @@ def update
3535
load_catalog
3636
if @catalog.update(catalog_params)
3737
@catalog.menu_items.update_all(link: catalog_url(@catalog), title: @catalog.title)
38-
redirect_to @catalog
38+
redirect_to menu_url(@catalog.menu)
3939
end
4040

4141
end

app/controllers/menus_controller.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class MenusController < ApplicationController
2-
2+
before_filter :authenticate_user!, only: [:show,:new, :edit, :update, :destroy]
3+
before_filter :correct_user, :only => [:show, :destroy, :edit , :update]
34

45
def show
56
load_menu

app/controllers/pages_controller.rb

+9-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@ def create
3838

3939
def update
4040
load_page
41-
if @page.update(page_params)
42-
@page.menu_items.update_all(link: page_url(@page), title: @page.title)
43-
redirect_to @page
41+
respond_to do |format|
42+
if @page.update(page_params)
43+
@page.menu_items.update_all(link: page_url(@page), title: @page.title)
44+
format.html { redirect_to @page, notice: 'Page was successfully updated.' }
45+
format.json { head :no_content }
46+
else
47+
format.html { render action: 'edit' }
48+
format.json { render json: @page.errors, status: :unprocessable_entity }
49+
end
4450
end
45-
4651
end
4752

4853

app/controllers/sites_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def set_site
8787

8888
# Never trust parameters from the scary internet, only allow the white list through.
8989
def site_params
90-
params.require(:site).permit(:domain, :sub_domain, :name, :user_id, :front_page_id, :remove_site_logo, :site_logo, :site_logo_cache, :image_slot_1_cache, :image_slot_1, :footer_text)
90+
params.require(:site).permit(:domain, :sub_domain, :name, :theme, :user_id, :front_page_id, :remove_site_logo, :site_logo, :site_logo_cache, :image_slot_1_cache, :image_slot_1, :footer_text)
9191
end
9292

9393

app/helpers/pages_helper.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module PagesHelper
22

33
def is_front?
4-
true if @page.id == current_site.front_page_id
4+
if @page
5+
true if @page.id == current_site.front_page_id
6+
end
57
end
68
end

app/helpers/sites_helper.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
module SitesHelper
2+
3+
def site_theme_select_options
4+
Site::THEMES.map { |theme| [t("site.firms.#{theme}"), theme] }
5+
end
6+
27
end

app/models/catalog_item.rb

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
#
33
# Table name: catalog_items
44
#
5-
# id :integer not null, primary key
6-
# category_id :integer
7-
# title :string(255)
8-
# slug :string(255)
9-
# price :integer
10-
# weight :integer
11-
# created_at :datetime
12-
# updated_at :datetime
5+
# id :integer not null, primary key
6+
# category_id :integer
7+
# title :string(255)
8+
# body :text
9+
# catalog_item_img :string(255)
10+
# slug :string(255)
11+
# price :integer
12+
# weight :integer
13+
# created_at :datetime
14+
# updated_at :datetime
1315
#
1416

1517
class CatalogItem < ActiveRecord::Base

app/models/category.rb

+18-9
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
22
#
33
# Table name: categories
44
#
5-
# id :integer not null, primary key
6-
# catalog_id :integer
7-
# title :string(255)
8-
# slug :string(255)
9-
# weight :integer
10-
# created_at :datetime
11-
# updated_at :datetime
5+
# id :integer not null, primary key
6+
# catalog_id :integer
7+
# title :string(255)
8+
# category_img :string(255)
9+
# slug :string(255)
10+
# weight :integer
11+
# created_at :datetime
12+
# updated_at :datetime
1213
#
1314

1415
class Category < ActiveRecord::Base
1516

1617
extend FriendlyId
17-
friendly_id :title, use: :slugged
18+
friendly_id :slug_candidates, use: :slugged
1819

1920
belongs_to :catalog
20-
has_many :catalog_items
21+
has_many :catalog_items, dependent: :destroy
2122

2223
mount_uploader :category_img, CategoryImgUploader
2324

2425
def should_generate_new_friendly_id?
2526
slug.blank? || title_changed?
2627
end
28+
29+
def slug_candidates
30+
[
31+
:title,
32+
[:title, Random.rand(1..10)],
33+
[:title, Random.rand(10..99)]
34+
]
35+
end
2736

2837
end

app/models/page.rb

-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#
1515

1616
class Page < ActiveRecord::Base
17-
# after_save :upfate_munu_item
1817

1918
validates :title, presence: true
2019

@@ -34,8 +33,4 @@ def should_generate_new_friendly_id?
3433
slug.blank? || title_changed?
3534
end
3635

37-
38-
# def upfate_munu_item
39-
# self.menu_items.each {|d| d.save! }
40-
# end
4136
end

0 commit comments

Comments
 (0)