thesis 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +103 -68
- data/app/assets/javascripts/thesis.js +1 -0
- data/app/assets/javascripts/thesis/thesis.coffee +250 -0
- data/app/assets/javascripts/thesis/utilities.coffee +13 -0
- data/app/assets/stylesheets/thesis.sass +4 -0
- data/app/assets/stylesheets/thesis/_mixins/_barber-pole.sass +5 -0
- data/app/assets/stylesheets/thesis/_mixins/editor.sass +15 -0
- data/app/assets/stylesheets/thesis/_thesis.sass +207 -0
- data/app/assets/stylesheets/thesis/base/_base.sass +5 -0
- data/app/assets/stylesheets/thesis/base/_colors.sass +6 -0
- data/app/assets/stylesheets/thesis/base/_fonts.sass +6 -0
- data/app/assets/stylesheets/thesis/base/_forms.scss +165 -0
- data/app/assets/stylesheets/thesis/base/_keyframes.sass +205 -0
- data/app/assets/stylesheets/thesis/base/bourbon/_bourbon-deprecated-upcoming.scss +8 -0
- data/app/assets/stylesheets/thesis/base/bourbon/_bourbon.scss +79 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_button.scss +374 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_clearfix.scss +23 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_directional-values.scss +111 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_ellipsis.scss +7 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_font-family.scss +5 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_hide-text.scss +10 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_html5-input-types.scss +86 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_position.scss +32 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_prefixer.scss +45 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_retina-image.scss +31 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_size.scss +16 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_timing-functions.scss +32 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_triangle.scss +83 -0
- data/app/assets/stylesheets/thesis/base/bourbon/addons/_word-wrap.scss +8 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_animation.scss +52 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_appearance.scss +3 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_backface-visibility.scss +6 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_background-image.scss +42 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_background.scss +55 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_border-image.scss +59 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_border-radius.scss +22 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_box-sizing.scss +4 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_calc.scss +4 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_columns.scss +47 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_filter.scss +5 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_flex-box.scss +321 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_font-face.scss +23 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_font-feature-settings.scss +10 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_hidpi-media-query.scss +10 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_hyphens.scss +4 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_image-rendering.scss +14 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_keyframes.scss +35 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_linear-gradient.scss +38 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_perspective.scss +8 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_placeholder.scss +8 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_radial-gradient.scss +39 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_transform.scss +15 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_transition.scss +77 -0
- data/app/assets/stylesheets/thesis/base/bourbon/css3/_user-select.scss +3 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_assign.scss +11 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_color-lightness.scss +13 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_flex-grid.scss +39 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_golden-ratio.scss +3 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_grid-width.scss +13 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_modular-scale.scss +66 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_px-to-em.scss +13 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_px-to-rem.scss +15 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_strip-units.scss +5 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_tint-shade.scss +9 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_transition-property-name.scss +22 -0
- data/app/assets/stylesheets/thesis/base/bourbon/functions/_unpack.scss +17 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_convert-units.scss +15 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_gradient-positions-parser.scss +13 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_is-num.scss +8 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_linear-angle-parser.scss +25 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_linear-gradient-parser.scss +41 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_linear-positions-parser.scss +61 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_radial-arg-parser.scss +69 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_radial-gradient-parser.scss +50 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_radial-positions-parser.scss +18 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_render-gradients.scss +26 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_shape-size-stripper.scss +10 -0
- data/app/assets/stylesheets/thesis/base/bourbon/helpers/_str-to-num.scss +50 -0
- data/app/assets/stylesheets/thesis/base/bourbon/settings/_asset-pipeline.scss +1 -0
- data/app/assets/stylesheets/thesis/base/bourbon/settings/_prefixer.scss +6 -0
- data/app/assets/stylesheets/thesis/base/bourbon/settings/_px-to-em.scss +1 -0
- data/lib/generators/thesis/install/install_generator.rb +21 -13
- data/lib/thesis/controllers/controller_helpers.rb +11 -5
- data/lib/thesis/controllers/thesis_controller.rb +16 -13
- data/lib/thesis/models/page.rb +29 -22
- data/lib/thesis/models/page_content.rb +44 -29
- data/lib/thesis/routing/route_constraint.rb +8 -2
- data/lib/thesis/routing/routes.rb +2 -3
- data/lib/thesis/version.rb +1 -1
- data/spec/factories/pages.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/{lib/thesis → thesis}/controllers/thesis_controller_spec.rb +15 -13
- data/spec/{lib/thesis → thesis}/models/page_content_spec.rb +4 -4
- data/spec/{lib/thesis → thesis}/models/page_spec.rb +0 -0
- data/spec/thesis/routing/thesis_routing_spec.rb +23 -0
- metadata +137 -56
- data/app/assets/javascripts/thesis/thesis.js.coffee +0 -157
- data/app/assets/stylesheets/thesis.css +0 -4
- data/app/assets/stylesheets/thesis/font-awesome/font-awesome.scss +0 -534
- data/app/assets/stylesheets/thesis/font/FontAwesome.otf +0 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.eot +0 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.svg +0 -284
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.ttf +0 -0
- data/app/assets/stylesheets/thesis/font/fontawesome-webfont.woff +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/animated-overlay.gif +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_glass_20_555555_1x400.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_4b8e0b_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_a83300_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_cccccc_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/stylesheets/thesis/jquery-ui/jquery-ui-1.10.2.custom.css +0 -1175
- data/app/assets/stylesheets/thesis/thesis.css.scss +0 -65
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 0289d1e4ff233b43abad3501bc115e5b5aeaef5f
|
|
4
|
+
data.tar.gz: 55c4b1fe9a040d4c28a84cc5a6418766cf8ce131
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 44bb0d0bb1729d409dbf66f40ca3223f667ebc340bccce20a78f2dd360c99011bb468cf07d5694dd73d00a55bf0f207e79db21505ffb2fd0ddb6431576076eaa
|
|
7
|
+
data.tar.gz: 7c76a9717a04dd81de8cf1d71ac5450027476e4daecdbe569912896c09bde52afd63cc8812d74a4158df8a755750f9f0a5384b5393c926e0cdf70e53efc4e21e
|
data/README.md
CHANGED
|
@@ -2,20 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
### Thesis is a Rails CMS gem that integrates as seamlessly as possible into your current Rails website.
|
|
4
4
|
|
|
5
|
-
Most Rails content management systems make you conform to their system from the start,
|
|
5
|
+
Most Rails content management systems make you conform to their system from the start,
|
|
6
6
|
making it difficult to just "drop in" the gem and make it work with your CMS. Thesis
|
|
7
7
|
tries to be a drop-in CMS that doesn't hijack your development workflow and stays out
|
|
8
8
|
of the way.
|
|
9
9
|
|
|
10
10
|
### Requirements
|
|
11
11
|
|
|
12
|
-
* Rails
|
|
12
|
+
* Rails 4.0.x (or higher)
|
|
13
13
|
* ActiveRecord on MySQL, PostgresQL, or SQLite3
|
|
14
|
-
* Ruby
|
|
14
|
+
* Ruby 2.0.0 (or higher)
|
|
15
15
|
* jQuery
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
Thesis *might* work with other versions but no guarantees.
|
|
16
|
+
* File hosting or Amazon S3 (for image upload)
|
|
19
17
|
|
|
20
18
|
## Getting Started
|
|
21
19
|
|
|
@@ -23,19 +21,41 @@ Thesis *might* work with other versions but no guarantees.
|
|
|
23
21
|
|
|
24
22
|
In your Gemfile:
|
|
25
23
|
|
|
26
|
-
gem 'thesis'
|
|
27
|
-
|
|
24
|
+
gem 'thesis', '~> 0.1'
|
|
25
|
+
|
|
28
26
|
Then run these from your command line:
|
|
29
27
|
|
|
30
28
|
bundle install
|
|
31
29
|
rails g thesis:install
|
|
32
30
|
rake db:migrate
|
|
33
|
-
|
|
31
|
+
|
|
34
32
|
This will install thesis and add the database tables.
|
|
35
33
|
|
|
34
|
+
[API Reference](#API)
|
|
35
|
+
|
|
36
|
+
## Using the CMS
|
|
37
|
+
|
|
38
|
+
### Adding a Page
|
|
39
|
+
|
|
40
|
+
TODO
|
|
41
|
+
|
|
42
|
+
### Editing a Page
|
|
43
|
+
|
|
44
|
+
TODO
|
|
45
|
+
|
|
46
|
+
### Deleting a Page
|
|
47
|
+
|
|
48
|
+
TODO
|
|
49
|
+
|
|
50
|
+
### Rearranging Pages
|
|
51
|
+
|
|
52
|
+
TODO
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
36
56
|
### Authentication
|
|
37
57
|
|
|
38
|
-
**Thesis does not force you to use a particular authentication strategy.**
|
|
58
|
+
**Thesis does not force you to use a particular user or authentication strategy.**
|
|
39
59
|
|
|
40
60
|
Instead, it adds a method into your application_controller.rb file that
|
|
41
61
|
allows you to hook up your own authentication logic.
|
|
@@ -43,109 +63,124 @@ allows you to hook up your own authentication logic.
|
|
|
43
63
|
* If you return `false` from this method, nothing will show up client-side nor will the page be editable.
|
|
44
64
|
* If you return `true` from this method, the Thesis editor will appear and the page will be editable.
|
|
45
65
|
|
|
66
|
+
#### Thesis authentication examples
|
|
67
|
+
|
|
46
68
|
```ruby
|
|
47
|
-
# Thesis authentication
|
|
48
69
|
def page_is_editable?(page)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
logged_in? && current_user.admin? # Devise + admin boolean
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def page_is_editable?(page)
|
|
74
|
+
can? :update, page # CanCanCan
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def page_is_editable?(page)
|
|
78
|
+
true # Just let everyone edit everything
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def page_is_editable?(page)
|
|
82
|
+
if current_user.admin?
|
|
83
|
+
true
|
|
84
|
+
elsif page.parent == Thesis::Page.find_by(name: "Blog")
|
|
85
|
+
true
|
|
86
|
+
else
|
|
87
|
+
false
|
|
88
|
+
end
|
|
53
89
|
end
|
|
54
90
|
```
|
|
55
91
|
|
|
92
|
+
### Models
|
|
93
|
+
|
|
94
|
+
Thesis creates two straightforward ActiveRecord tables: pages and page_contents. Since they're normal ActiveRecord models, you're free to use them in your code however you want.
|
|
95
|
+
|
|
96
|
+
#### Thesis::Page
|
|
97
|
+
|
|
98
|
+
t.integer :parent_id
|
|
99
|
+
t.string :name
|
|
100
|
+
t.string :slug
|
|
101
|
+
t.string :title
|
|
102
|
+
t.string :description
|
|
103
|
+
t.integer :sort_order, default: 0, null: false
|
|
104
|
+
t.string :template, default: "default", null: false
|
|
105
|
+
t.timestamps
|
|
106
|
+
|
|
107
|
+
#### Thesis::PageContent
|
|
108
|
+
|
|
109
|
+
t.integer :page_id, null: false
|
|
110
|
+
t.string :name, null: false
|
|
111
|
+
t.text :content, default: "Edit This Content Area"
|
|
112
|
+
t.string :content_type, default: :html
|
|
113
|
+
t.timestamps
|
|
114
|
+
|
|
56
115
|
### Page Templates
|
|
57
116
|
|
|
58
117
|
Thesis's installer will drop a `page_templates` folder into your `app/views` folder.
|
|
59
118
|
This is where you put different styles of pages for use in the CMS.
|
|
60
119
|
Thesis will install an ERB, [HAML](http://haml.info), or [Slim](http://slim-lang.com) version, depending on your configuration.
|
|
61
120
|
|
|
62
|
-
|
|
121
|
+
### Meta information
|
|
63
122
|
|
|
64
|
-
Pages come with a few built-in fields for use in meta tags.
|
|
123
|
+
Pages come with a few built-in fields for use in SEO meta tags.
|
|
65
124
|
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
|
|
125
|
+
```slim
|
|
126
|
+
head
|
|
127
|
+
title = current_page.title || "Default Title"
|
|
128
|
+
meta content="#{current_page.description}" type="description"
|
|
69
129
|
```
|
|
70
130
|
|
|
71
|
-
|
|
131
|
+
### Thesis Editor
|
|
72
132
|
|
|
73
133
|
Place this right after your opening `body` tag to embed the Thesis editor. It will only show
|
|
74
134
|
up if your `page_is_editable?` method returns `true`.
|
|
75
135
|
|
|
76
|
-
```
|
|
77
|
-
|
|
136
|
+
```slim
|
|
137
|
+
body
|
|
78
138
|
= thesis_editor
|
|
79
139
|
```
|
|
80
140
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
```haml
|
|
84
|
-
%h1= current_page.title
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
#### Primary Navigation
|
|
141
|
+
### Primary Navigation
|
|
88
142
|
|
|
89
143
|
Use `root_pages` to get a list of pages at the root level. You can use the
|
|
90
144
|
page's `name` and `path` accessors in your links.
|
|
91
145
|
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
146
|
+
```slim
|
|
147
|
+
nav
|
|
148
|
+
ul
|
|
149
|
+
li = link_to "Home", root_path # You can mix and match dynamic and static pages
|
|
96
150
|
- root_pages.each do |p|
|
|
97
|
-
|
|
98
|
-
|
|
151
|
+
li = link_to p.name, p.path
|
|
152
|
+
li = link_to "Static Page", static_page_path
|
|
99
153
|
```
|
|
100
154
|
|
|
101
|
-
|
|
155
|
+
### Page content
|
|
102
156
|
|
|
103
157
|
Content areas are accessible from any page using the `content` method. This method
|
|
104
158
|
takes two arguments: name and type. Type defaults to `:html`. The only other type
|
|
105
159
|
is `:text` (for now) which is plain text, no HTML accepted. `:image` will be added soon.
|
|
106
160
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Referencing a content area in a page template will create one if it doesn't exist already.
|
|
161
|
+
Referencing a content area in a page template will create one if it doesn't exist already, using the `default:` value.
|
|
110
162
|
|
|
111
|
-
```
|
|
112
|
-
|
|
163
|
+
```slim
|
|
164
|
+
article
|
|
113
165
|
= current_page.content("Main Content", :html, default: "<p>This is my default HTML content.<p>")
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
166
|
+
= current_page.content("Splash Image", :image, default: "/assets/default-image.jpg") # coming soon
|
|
167
|
+
aside
|
|
168
|
+
= current_page.content("Sidebar Content", :html)
|
|
169
|
+
footer
|
|
170
|
+
p = current_page.content("Footer Content", :text, default: "Copyright Me")
|
|
118
171
|
```
|
|
119
172
|
|
|
120
173
|
### Routing
|
|
121
|
-
|
|
174
|
+
|
|
122
175
|
Thesis will automatically handle routes for pages you create with Thesis. Your
|
|
123
176
|
routes will take precedence over Thesis-created pages, so if you create a page
|
|
124
|
-
with Thesis called "About" and you already have a route for
|
|
177
|
+
with Thesis called "About" and you already have a route for
|
|
125
178
|
`get "about" => "something#else"` Thesis won't show the page.
|
|
126
|
-
|
|
127
|
-
## Using the CMS
|
|
128
|
-
|
|
129
|
-
### Adding a Page
|
|
130
|
-
|
|
131
|
-
TODO
|
|
132
|
-
|
|
133
|
-
### Editing a Page
|
|
134
|
-
|
|
135
|
-
TODO
|
|
136
|
-
|
|
137
|
-
### Deleting a Page
|
|
138
|
-
|
|
139
|
-
TODO
|
|
140
|
-
|
|
141
|
-
### Rearranging Pages
|
|
142
|
-
|
|
143
|
-
TODO
|
|
144
179
|
|
|
145
180
|
## What Thesis Isn't
|
|
146
181
|
|
|
147
|
-
You can't have it all. Thesis isn't the same as other -bloated- full-functioned
|
|
148
|
-
content management systems out there. This is a list of what it's not now and
|
|
182
|
+
You can't have it all. Thesis isn't the same as other -bloated- full-functioned
|
|
183
|
+
content management systems out there. This is a list of what it's not now and
|
|
149
184
|
not likely to be in the future.
|
|
150
185
|
|
|
151
186
|
*We reserve the right to change our mind, however, especially with well planned and written
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Thesis =
|
|
2
|
+
setup: ->
|
|
3
|
+
@edit_mode = false
|
|
4
|
+
if this.requirements() && this.page_is_editable()
|
|
5
|
+
this.draw_editor()
|
|
6
|
+
this.set_up_bindings()
|
|
7
|
+
|
|
8
|
+
requirements: ->
|
|
9
|
+
if jQuery.ui
|
|
10
|
+
true
|
|
11
|
+
else
|
|
12
|
+
alert "jQuery UI not included. Thesis will not work properly without it."
|
|
13
|
+
false
|
|
14
|
+
|
|
15
|
+
edit_mode: ->
|
|
16
|
+
@edit_mode
|
|
17
|
+
|
|
18
|
+
thesis: ->
|
|
19
|
+
@thesis = $("#thesis-editor")
|
|
20
|
+
|
|
21
|
+
# ATTRIBUTES
|
|
22
|
+
page_is_editable: ->
|
|
23
|
+
this.thesis().length > 0
|
|
24
|
+
|
|
25
|
+
page_in_edit_mode: ->
|
|
26
|
+
$("body").hasClass("thesis-editing")
|
|
27
|
+
|
|
28
|
+
page_has_unsaved_content: ->
|
|
29
|
+
$("body .thesis-content.isModified").length
|
|
30
|
+
|
|
31
|
+
modal: (blur=false, type="settings")->
|
|
32
|
+
this.close_modal()
|
|
33
|
+
$("body").addClass "thesis-blur" if blur
|
|
34
|
+
$("body").append this["#{type}_modal_markup"]()
|
|
35
|
+
$("#thesis-modal").fadeIn 300
|
|
36
|
+
|
|
37
|
+
$("#thesis-modal").on "click", ".modal-field.cancel", (e)->
|
|
38
|
+
e.preventDefault()
|
|
39
|
+
Thesis.close_modal()
|
|
40
|
+
|
|
41
|
+
$("#thesis-modal").on "submit", "form", (e) ->
|
|
42
|
+
alert "To Do: submit form"
|
|
43
|
+
e.preventDefault() #temp
|
|
44
|
+
return false #temp
|
|
45
|
+
|
|
46
|
+
close_modal: ->
|
|
47
|
+
if $("#thesis-modal").length
|
|
48
|
+
$("body").removeClass "thesis-blur"
|
|
49
|
+
$("#thesis-modal").remove()
|
|
50
|
+
|
|
51
|
+
settings_modal_markup: ->
|
|
52
|
+
is_win = navigator.appVersion.indexOf("Win")!=-1
|
|
53
|
+
"""
|
|
54
|
+
<div id="thesis-modal" class="settings #{if is_win then 'windows' else ''}">
|
|
55
|
+
<div class="modal-icon"><i class="fa fa-wrench fa-2x"></i></div>
|
|
56
|
+
<div class="modal-title">Page Settings</div>
|
|
57
|
+
<form action="" method="">
|
|
58
|
+
<label class="modal-field"><span>Page Name</span><input class="page-settings_page-title" name="page-settings_page-title" type="text" /></label>
|
|
59
|
+
<label class="modal-field"><span>Page Slug</span><input class="page-settings_page-slug" name="page-settings_page-slug" type="text" /></label>
|
|
60
|
+
<label class="modal-field"><span>Meta Title</span><input class="page-settings_meta-title" name="page-settings_meta-title" type="text" /></label>
|
|
61
|
+
<label class="modal-field"><span>Meta Description</span><textarea class="page-settings_meta-description" name="page-settings_meta-description"></textarea></label>
|
|
62
|
+
<label class="modal-field cancel"><button class="page-settings_submit" name="page-settings_submit"><i class="fa fa-remove fa-2x"></i> <span>Cancel</span></button></label>
|
|
63
|
+
<label class="modal-field submit"><button class="page-settings_submit" name="page-settings_submit" type="Submit" value=""><i class="fa fa-save fa-2x"></i> <span>Save</span></button></label>
|
|
64
|
+
</form>
|
|
65
|
+
</div>
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
# ACTIONS
|
|
69
|
+
set_up_bindings: ->
|
|
70
|
+
t = this
|
|
71
|
+
|
|
72
|
+
t.thesis.on "mouseenter", ->
|
|
73
|
+
clearTimeout @hide_editor_delay
|
|
74
|
+
$(this).addClass "active"
|
|
75
|
+
.on "mouseleave", ->
|
|
76
|
+
@hide_editor_delay = Utilities.delay 2000, ()=>
|
|
77
|
+
$(this).removeClass "active"
|
|
78
|
+
|
|
79
|
+
@edit_page_button.on "mouseenter", ->
|
|
80
|
+
t.change_edit_tooltip_status()
|
|
81
|
+
|
|
82
|
+
@edit_page_button.on "click", (e) ->
|
|
83
|
+
e.preventDefault()
|
|
84
|
+
t.edit_button_click_actions()
|
|
85
|
+
|
|
86
|
+
edit_button_click_actions: ->
|
|
87
|
+
if this.page_in_edit_mode()
|
|
88
|
+
if this.page_has_unsaved_content()
|
|
89
|
+
this.change_edit_tooltip_status("Save Page before Exiting", "error")
|
|
90
|
+
else
|
|
91
|
+
this.end_editing()
|
|
92
|
+
else
|
|
93
|
+
this.start_editing()
|
|
94
|
+
|
|
95
|
+
change_edit_tooltip_status: (edit_text=null, classes=null) ->
|
|
96
|
+
$tooltip = @edit_page_button.find(".tooltip")
|
|
97
|
+
$tooltip.removeClass().addClass("tooltip")
|
|
98
|
+
$tooltip.addClass "#{classes}" if classes
|
|
99
|
+
unless edit_text
|
|
100
|
+
if this.page_in_edit_mode()
|
|
101
|
+
if this.page_has_unsaved_content()
|
|
102
|
+
edit_text = "Editing Page"
|
|
103
|
+
else
|
|
104
|
+
edit_text = "Exit Edit Mode"
|
|
105
|
+
else
|
|
106
|
+
edit_text = "Edit Page"
|
|
107
|
+
$tooltip.text edit_text
|
|
108
|
+
|
|
109
|
+
start_editing: ->
|
|
110
|
+
$("body").append($("<div></div>").addClass("thesis-fader"))
|
|
111
|
+
$("body").addClass("thesis-editing")
|
|
112
|
+
$(".thesis-content-html").hallo this.hallo_html_options()
|
|
113
|
+
$(".thesis-content-text").hallo this.hallo_text_options()
|
|
114
|
+
this.change_edit_tooltip_status()
|
|
115
|
+
|
|
116
|
+
end_editing: ->
|
|
117
|
+
$(".thesis-fader").remove()
|
|
118
|
+
$("body").removeClass("thesis-editing")
|
|
119
|
+
$(".thesis-content-html").hallo editable: false
|
|
120
|
+
$(".thesis-content-text").hallo editable: false
|
|
121
|
+
this.change_edit_tooltip_status()
|
|
122
|
+
|
|
123
|
+
save_content: ->
|
|
124
|
+
# Gather the content for posting
|
|
125
|
+
payload = {}
|
|
126
|
+
$(".thesis-content-html, .thesis-content-text").each ()->
|
|
127
|
+
content_area = $(this)
|
|
128
|
+
content_id = content_area.data("thesis-content-id")
|
|
129
|
+
payload[content_id] = content_area.html()
|
|
130
|
+
|
|
131
|
+
$.ajax
|
|
132
|
+
url: "/thesis/update_page_content"
|
|
133
|
+
data: payload
|
|
134
|
+
type: "put"
|
|
135
|
+
dataType: "json"
|
|
136
|
+
success: ->
|
|
137
|
+
alert "Page saved."
|
|
138
|
+
error: ->
|
|
139
|
+
alert "Sorry, couldn't save this page."
|
|
140
|
+
|
|
141
|
+
add_page: ->
|
|
142
|
+
page_name = prompt "What is the name of the new page?"
|
|
143
|
+
if page_name
|
|
144
|
+
parent_slug = null
|
|
145
|
+
if confirm("Make this a subpage of the current page?")
|
|
146
|
+
parent_slug = window.location.pathname
|
|
147
|
+
$.ajax
|
|
148
|
+
url: "/thesis/create_page"
|
|
149
|
+
data:
|
|
150
|
+
name: page_name
|
|
151
|
+
parent_slug: parent_slug
|
|
152
|
+
type: "post"
|
|
153
|
+
dataType: "json"
|
|
154
|
+
success: (resp, status, xhr)->
|
|
155
|
+
if resp && resp.page
|
|
156
|
+
window.location = resp.page.slug
|
|
157
|
+
else
|
|
158
|
+
alert "Unknown error"
|
|
159
|
+
error: ->
|
|
160
|
+
alert "Sorry, couldn't save this page."
|
|
161
|
+
|
|
162
|
+
delete_page: ->
|
|
163
|
+
really_sure = confirm "Are you sure you want to delete this page? There is no undo!"
|
|
164
|
+
if really_sure
|
|
165
|
+
$.ajax
|
|
166
|
+
url: "/thesis/delete_page"
|
|
167
|
+
data:
|
|
168
|
+
slug: window.location.pathname
|
|
169
|
+
type: "delete"
|
|
170
|
+
# dataType: "json"
|
|
171
|
+
success: ->
|
|
172
|
+
alert "Page was deleted."
|
|
173
|
+
error: ->
|
|
174
|
+
alert "Sorry, couldn't delete this page."
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# OPTIONS
|
|
178
|
+
hallo_text_options: ->
|
|
179
|
+
options =
|
|
180
|
+
editable: true
|
|
181
|
+
|
|
182
|
+
hallo_html_options: ->
|
|
183
|
+
options =
|
|
184
|
+
editable: true
|
|
185
|
+
plugins:
|
|
186
|
+
'halloformat': {}
|
|
187
|
+
'halloheadings': {}
|
|
188
|
+
'hallojustify': {}
|
|
189
|
+
'hallolists': {}
|
|
190
|
+
'halloreundo': {}
|
|
191
|
+
'hallolink': {}
|
|
192
|
+
# 'halloimage': {} # Someday?
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
# EDITOR
|
|
196
|
+
draw_editor: ->
|
|
197
|
+
@thesis.append(this.draw_add_icon())
|
|
198
|
+
@thesis.append(this.draw_delete_icon())
|
|
199
|
+
@thesis.append(this.draw_settings_icon())
|
|
200
|
+
@thesis.append(this.draw_cancel_icon())
|
|
201
|
+
@thesis.append(this.draw_save_icon())
|
|
202
|
+
@thesis.append(this.draw_edit_icon())
|
|
203
|
+
@edit_page_button = @thesis.find(".thesis-button.edit")
|
|
204
|
+
|
|
205
|
+
draw_edit_icon: ->
|
|
206
|
+
$icon = $("<i></i>").addClass "fa fa-edit fa-2x"
|
|
207
|
+
$tooltip = $("<div></div>").addClass("tooltip").text "Edit Page"
|
|
208
|
+
$("<div></div>").addClass("thesis-button edit").append $tooltip, $icon
|
|
209
|
+
|
|
210
|
+
draw_save_icon: ->
|
|
211
|
+
$icon = $("<i></i>").addClass "fa fa-save fa-2x"
|
|
212
|
+
$tooltip = $("<div></div>").addClass("tooltip").text "Save Changes"
|
|
213
|
+
$button = $("<div></div>").addClass("thesis-button save").append $tooltip, $icon
|
|
214
|
+
$button.on "click", ->
|
|
215
|
+
Thesis.save_content()
|
|
216
|
+
Thesis.end_editing()
|
|
217
|
+
|
|
218
|
+
draw_add_icon: ->
|
|
219
|
+
$icon = $("<i></i>").addClass "fa fa-plus fa-2x"
|
|
220
|
+
$tooltip = $("<div></div>").addClass("tooltip").text "Add New Page"
|
|
221
|
+
$button = $("<div></div>").addClass("thesis-button add").append $tooltip, $icon
|
|
222
|
+
$button.on "click", ->
|
|
223
|
+
Thesis.add_page()
|
|
224
|
+
|
|
225
|
+
draw_settings_icon: ->
|
|
226
|
+
$icon = $("<i></i>").addClass "fa fa-wrench fa-2x"
|
|
227
|
+
$tooltip = $("<div></div>").addClass("tooltip").text "Page Settings"
|
|
228
|
+
$button = $("<div></div>").addClass("thesis-button settings").append $tooltip, $icon
|
|
229
|
+
$button.on "click", ->
|
|
230
|
+
Thesis.modal(true, "settings")
|
|
231
|
+
|
|
232
|
+
draw_delete_icon: ->
|
|
233
|
+
$icon = $("<i></i>").addClass "fa fa-trash fa-2x"
|
|
234
|
+
$tooltip = $("<div></div>").addClass("tooltip").text "Delete Page"
|
|
235
|
+
$button = $("<div></div>").addClass("thesis-button delete").append $tooltip, $icon
|
|
236
|
+
$button.on "click", ->
|
|
237
|
+
Thesis.delete_page()
|
|
238
|
+
|
|
239
|
+
draw_cancel_icon: ->
|
|
240
|
+
$icon = $("<i></i>").addClass "fa fa-remove fa-2x"
|
|
241
|
+
$tooltip = $("<div></div>").addClass("tooltip").text "Discard Changes"
|
|
242
|
+
$button = $("<div></div>").addClass("thesis-button cancel").append $tooltip, $icon
|
|
243
|
+
$button.on "click", ->
|
|
244
|
+
Thesis.end_editing()
|
|
245
|
+
location.reload()
|
|
246
|
+
|
|
247
|
+
jQuery ($)->
|
|
248
|
+
Thesis.setup()
|
|
249
|
+
|
|
250
|
+
# window.Thesis = Thesis # Enable if necessary
|