seamess 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +166 -0
  4. data/Rakefile +24 -0
  5. data/app/assets/config/seamess_manifest.js +2 -0
  6. data/app/assets/javascripts/seamess/application.js +13 -0
  7. data/app/assets/javascripts/seamess/manager.js +6 -0
  8. data/app/assets/stylesheets/seamess/manager.sass +2 -0
  9. data/app/assets/stylesheets/seamess/partials/footer.sass +7 -0
  10. data/app/assets/stylesheets/seamess/partials/layouts.sass +19 -0
  11. data/app/assets/stylesheets/seamess/partials/manager.sass +48 -0
  12. data/app/assets/stylesheets/seamess/partials/masthead.sass +27 -0
  13. data/app/assets/stylesheets/seamess/partials/shared.sass +5 -0
  14. data/app/assets/stylesheets/seamess/partials/variables.sass +2 -0
  15. data/app/assets/stylesheets/seamess/seamess.sass +1 -0
  16. data/app/controllers/seamess/application_controller.rb +5 -0
  17. data/app/controllers/seamess/manager/base_controller.rb +5 -0
  18. data/app/controllers/seamess/manager/dashboard_controller.rb +4 -0
  19. data/app/controllers/seamess/manager/pages_controller.rb +52 -0
  20. data/app/controllers/seamess/pages_controller.rb +10 -0
  21. data/app/helpers/seamess/application_helper.rb +4 -0
  22. data/app/jobs/seamess/application_job.rb +4 -0
  23. data/app/mailers/seamess/application_mailer.rb +6 -0
  24. data/app/models/seamess/application_record.rb +5 -0
  25. data/app/models/seamess/page.rb +16 -0
  26. data/app/views/layouts/seamess/application.html.haml +16 -0
  27. data/app/views/layouts/seamess/columnar.html.haml +3 -0
  28. data/app/views/layouts/seamess/fluid.html.haml +3 -0
  29. data/app/views/layouts/seamess/manager.html.haml +19 -0
  30. data/app/views/layouts/seamess/pages.html.haml +5 -0
  31. data/app/views/seamess/common/_after_head.html.haml +3 -0
  32. data/app/views/seamess/common/_after_yield.html.haml +7 -0
  33. data/app/views/seamess/common/_before_yield.html.haml +5 -0
  34. data/app/views/seamess/common/_callouts.html.haml +1 -0
  35. data/app/views/seamess/common/_drip.html.haml +13 -0
  36. data/app/views/seamess/common/_facebook_pixel.html.haml +13 -0
  37. data/app/views/seamess/common/_footer.html.haml +1 -0
  38. data/app/views/seamess/common/_google_analytics.html.haml +10 -0
  39. data/app/views/seamess/common/_head.html.haml +12 -0
  40. data/app/views/seamess/common/_javascripts.html.haml +3 -0
  41. data/app/views/seamess/common/_manager_sidebar.html.haml +13 -0
  42. data/app/views/seamess/common/_navbar.html.haml +18 -0
  43. data/app/views/seamess/manager/dashboard/dashboard.html.haml +1 -0
  44. data/app/views/seamess/manager/pages/_form.html.haml +8 -0
  45. data/app/views/seamess/manager/pages/edit.html.haml +4 -0
  46. data/app/views/seamess/manager/pages/index.html.haml +21 -0
  47. data/app/views/seamess/manager/pages/new.html.haml +3 -0
  48. data/app/views/seamess/pages/show.html.haml +2 -0
  49. data/app/views/seamess/pages/styles.html.haml +50 -0
  50. data/config/initializers/simple_form.rb +209 -0
  51. data/config/routes.rb +14 -0
  52. data/db/migrate/20170827174002_create_seamess_pages.rb +10 -0
  53. data/db/migrate/20170829085602_change_seamess_pages_slug_to_nullable.rb +9 -0
  54. data/db/seeds.rb +25 -0
  55. data/lib/seamess.rb +14 -0
  56. data/lib/seamess/engine.rb +9 -0
  57. data/lib/seamess/version.rb +3 -0
  58. data/lib/tasks/seamess_tasks.rake +4 -0
  59. metadata +269 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 174418a66944d3e44dfc49ddb71b64209a657967
4
+ data.tar.gz: 76f18b85d38b29b5805d45ee7fccc49bdde4538b
5
+ SHA512:
6
+ metadata.gz: 5d2fb41b5ba975c69927313b7929b5e5236ea313c82e873b5c00bfe15a2e9643f06516e3c9794a464132fc880366e687d0872d9b8be8b25865fbdbae942597ad
7
+ data.tar.gz: 96e03522cc4dc56b307123338147fe3f78c7aad9731a35ace1e039cac6ce3f6570cc9b0f74b0a9b2746f0420ee7590613bbae066d4fa02dd0223a440b90a0a60
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Ridgeway Digital Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,166 @@
1
+ # Seamess
2
+
3
+ Seamess is an extremely opinionated CMS framework.
4
+
5
+ (To be more clear, *I* am opinionated. It is just an inert pile of code. But the effect is the same.)
6
+
7
+ Seamess is a Rails 5.1-based engine that can be used with any other Rack app.
8
+
9
+ It also uses:
10
+
11
+ - Bootstrap 4 beta
12
+ - jQuery 3
13
+ - haml
14
+ - sass (indented style, not bracket style)
15
+
16
+ And when I say it's opinionated, I mean that I won't entertain requests to change any of the above.
17
+
18
+ It's also opinionated because it believes and enforces the following:
19
+
20
+ 1. Page structure should be flat, but slugs should be wholly in the hands of the user. So if you want to nest a page, go ahead and create `my-page/` and `my-page/sub-page/`.
21
+ 2. Posts and pages should be written in Markdown. Fancy editors break stuff. Learn Markdown, you scrub.
22
+ 3. Few moving parts. No generators. Those things are murder to maintain.
23
+ 4. Max depth of two namespaces, and preferrably only one.
24
+ 5. Maybe more. I'm not 100% solid on the other stuff yet.
25
+
26
+ ## Usage
27
+
28
+ ### Installation
29
+
30
+ Install the gem into your Rack application by adding to `Gemfile`:
31
+
32
+ ```ruby
33
+ gem 'seamess'
34
+ ```
35
+
36
+ Don't forget to `bundle`.
37
+
38
+ Mount the engine in your `config/routes.rb`:
39
+
40
+ ```ruby
41
+ Rails.application.routes.draw do
42
+ mount Seamess::Engine, at: "/my-path"
43
+ root to: "some_controller#some_action"
44
+ end
45
+ ```
46
+
47
+ If you're going to serve the application at the root of your site, change that
48
+ to this:
49
+
50
+ ```ruby
51
+ Rails.application.routes.draw do
52
+ mount Seamess::Engine, at: "/"
53
+ root to: Seamess::Engine
54
+ end
55
+ ```
56
+
57
+ ### Migrations / Seeds
58
+
59
+ Add to `db/seeds.rb`:
60
+
61
+ ```ruby
62
+ Seamess::Engine.load_seed
63
+ ```
64
+
65
+ Then run `rake seamess:install:migrations db:migrate db:seed`.
66
+
67
+ ### Assets
68
+
69
+ Seamess defines base stylesheets but expects that you will override them. So you have to actually create your own, and use sass imports to bring the Seamess sheets into your site. This gives you the bonus of being able to override any variables we define.
70
+
71
+ Create the `app/assets/stylesheets/partials` directory and create `app/assets/stylesheets/partials/variables.sass` within it.
72
+
73
+ Create `app/assets/stylesheets/application.(scss|sass)` and add to it:
74
+
75
+ ```sass
76
+ @import "partials/variables"
77
+ @import "seamess/seamess"
78
+ ```
79
+
80
+ Create `app/assets/stylesheets/manager.(scss|sass)` and add to it:
81
+
82
+ ```sass
83
+ @import "partials/variables"
84
+ @import "seamess/manager"
85
+ ```
86
+
87
+ ### Layouts
88
+
89
+ Create `app/views/layouts/application.html.haml` and add the following content:
90
+
91
+ ```haml
92
+ = extends :'layouts/seamess/application'
93
+ ```
94
+
95
+ Seamess also ships with a few layouts:
96
+
97
+ `seamess/application`
98
+ : The base template. Gives you the basics. You should probably not use this layout, but extend it on your own.
99
+
100
+ `seamess/columnar`
101
+ : A basic template that can be used for a 12-column reduced-width grid layout. You'd use this on most pages, unless you want a full-width layout. Note that this layout extends from `application`, not `seamess/application`.
102
+
103
+ `seamess/fluid`
104
+ : Another basic template that uses Bootstrap's `.container-fluid` styling for a full-width responsive display. This also extends from `application`, not `seamess/application`.
105
+
106
+ `seamess/pages`
107
+ : A template which extends `seamess/columnar`. I use it to display full-width pages, which look a little bulky when they are the full 12 columns. So this template provides a simple wrapper to further shrink down columnar content.
108
+
109
+ `seamess/manager`
110
+ : A template which is used for the manager. This extends from `seamess/fluid`. In general, you probably don't want to mess around with this one.
111
+
112
+ Seamess makes great use out of the `nestive` gem for parent/child layouts, and for denoting overridable content chunks. **If you override a template that has a slash in it, you must prepend `layout/`, or the layout won't be found.**
113
+
114
+ Nestive does let us do some pretty amazing things. For example, the default brand in Seamess is just controlled by `ENV['SITE_TITLE']`. But say we want to replace that with something interesting. The layout inheritance lets us do something like the following:
115
+
116
+ ```haml
117
+ -# app/views/layouts/application.html.haml
118
+ = extends :'layouts/seamess/application' do
119
+ = replace :nav_brand do
120
+ = link_to seamess.root_url, class: "navbar-brand" do
121
+ %span.something-funky MyBrand
122
+
123
+ -# You need to have 'yield' here or else body content will be missing.
124
+ = yield
125
+ ```
126
+
127
+ Since all of Seamess's layouts inherit from the main app's `application` layout (excepting `application`), this will be present on all of the site's pages.
128
+
129
+ ## Integrating
130
+
131
+ ### Users
132
+
133
+ You must have at very least a user class in your home application. It's
134
+ recommended that you also have an `Admin` class. Be sure to set these in an
135
+ initializer:
136
+
137
+ ```ruby
138
+ Seamess.admin_class = "Admin"
139
+ ```
140
+
141
+ Seamess also makes the assumption that the following methods will be available
142
+ to it within both controllers and views:
143
+
144
+ - `authenticate_admin!`
145
+ - `current_admin`
146
+ - `admin_signed_in?`
147
+
148
+ And looks for the following route:
149
+
150
+ - `main_app.destroy_admin_session_path [DELETE]`
151
+
152
+ You should make sure these are defined in your ApplicationHelper and set as view
153
+ helpers if they aren't already done so for you. (Coincidentally, if you're using
154
+ Devise in your host app with an `Admin` class, this is done for you! How easy.)
155
+
156
+ ### Devise
157
+
158
+ Be sure to set `config.router_name = :main_app` in your
159
+ `config/initializers/devise.rb` if you choose Devise for your users.
160
+
161
+ ## Contributing
162
+
163
+ It's still private. Just ping me.
164
+
165
+ ## License
166
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Seamess'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ require 'bundler/gem_tasks'
24
+
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/seamess .js
2
+ //= link_directory ../stylesheets/seamess .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,6 @@
1
+ //= require rails-ujs
2
+ //= require turbolinks
3
+ //= require jquery3
4
+ //= require popper
5
+ //= require bootstrap-sprockets
6
+ //= require_self
@@ -0,0 +1,2 @@
1
+ @import "seamess/partials/shared"
2
+ @import "seamess/partials/manager"
@@ -0,0 +1,7 @@
1
+ footer
2
+ @extend .py-4
3
+ @extend .px-1
4
+ @extend .mt-5
5
+ @extend .text-center
6
+ @extend .text-muted
7
+ background-color: $footer-background-color
@@ -0,0 +1,19 @@
1
+ main
2
+ body.columnar &
3
+ @extend .container
4
+ @extend .mt-5
5
+
6
+ h1
7
+ @extend .mb-4
8
+
9
+ body.fluid &
10
+ @extend .container-fluid
11
+
12
+ body.pages &
13
+ .content
14
+ @extend .row
15
+ @extend .justify-content-center
16
+
17
+ .text
18
+ @extend .col-12
19
+ @extend .col-md-8
@@ -0,0 +1,48 @@
1
+ .sidebar-container
2
+ @extend .row
3
+
4
+ nav
5
+ @extend .col-sm-3
6
+ @extend .col-md-2
7
+ @extend .d-none
8
+ @extend .d-sm-block
9
+ @extend .bg-light
10
+
11
+ position: fixed
12
+ top: $admin-navbar-height
13
+ bottom: 0
14
+ left: 0
15
+ z-index: 1000
16
+ padding: 20px 0
17
+ overflow-x: hidden
18
+ overflow-y: auto
19
+ border-right: 1px solid #eee
20
+
21
+ .nav
22
+ margin-bottom: 20px
23
+
24
+ .nav-item
25
+ width: 100%
26
+
27
+ .nav-item + .nav-item
28
+ margin-left: 0
29
+
30
+ .nav-link
31
+ border-radius: 0
32
+
33
+ .content
34
+ @extend .col-sm-9
35
+ @extend .ml-sm-auto
36
+ @extend .col-md-10
37
+ @extend .py-3
38
+
39
+ margin-top: $admin-navbar-height
40
+
41
+ .actions
42
+ @extend .text-right
43
+ @extend .pr-5
44
+
45
+ h1
46
+ @extend .mb-5
47
+ @extend .pb-3
48
+ border-bottom: 1px solid #eee
@@ -0,0 +1,27 @@
1
+ header.masthead
2
+ body.columnar &
3
+ @extend .container
4
+
5
+ nav
6
+ @extend .navbar
7
+ @extend .navbar-expand-md
8
+ @extend .navbar-light
9
+ @extend .bg-white
10
+
11
+ body.columnar &
12
+ @extend .row
13
+
14
+ body.admin &
15
+ @extend .fixed-top
16
+
17
+ body.admin &
18
+ @extend .navbar-dark
19
+ @extend .bg-dark
20
+
21
+ #navbar-contents
22
+ @extend .collapse
23
+ @extend .navbar-collapse
24
+
25
+ > ul
26
+ @extend .ml-auto
27
+
@@ -0,0 +1,5 @@
1
+ @import "bootstrap"
2
+ @import "seamess/partials/variables"
3
+ @import "seamess/partials/layouts"
4
+ @import "seamess/partials/masthead"
5
+ @import "seamess/partials/footer"
@@ -0,0 +1,2 @@
1
+ $footer-background-color: #222 !default
2
+ $admin-navbar-height: 56px !default
@@ -0,0 +1 @@
1
+ @import "seamess/partials/shared"
@@ -0,0 +1,5 @@
1
+ module Seamess
2
+ class ApplicationController < ::ApplicationController
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Seamess::Manager::BaseController < Seamess::ApplicationController
2
+ layout "seamess/manager"
3
+
4
+ before_action :authenticate_admin!
5
+ end
@@ -0,0 +1,4 @@
1
+ class Seamess::Manager::DashboardController < Seamess::Manager::BaseController
2
+ def dashboard
3
+ end
4
+ end
@@ -0,0 +1,52 @@
1
+ class Seamess::Manager::PagesController < Seamess::Manager::BaseController
2
+
3
+ def index
4
+ @pages = Seamess::Page.for_manager_index
5
+ end
6
+
7
+ def show
8
+ @page = Seamess::Page.find(params[:id])
9
+ end
10
+
11
+ def new
12
+ @page = Seamess::Page.new
13
+ end
14
+
15
+ def create
16
+ @page = Seamess::Page.new(page_create_params)
17
+
18
+ if @page.save
19
+ flash[:success] = "Saved the page."
20
+ redirect_to seamess.manager_pages_path
21
+ else
22
+ flash[:error] = "Something went wrong:"
23
+ render :new
24
+ end
25
+ end
26
+
27
+ def edit
28
+ @page = Seamess::Page.find(params[:id])
29
+ end
30
+
31
+ def update
32
+ @page = Seamess::Page.find(params[:id])
33
+
34
+ if @page.update_attributes(page_update_params)
35
+ flash[:success] = "Updated the page."
36
+ redirect_to seamess.manager_pages_path
37
+ else
38
+ flash[:error] = "Something went wrong:"
39
+ render :edit
40
+ end
41
+ end
42
+
43
+ private def page_create_params
44
+ params.require(:page).permit(
45
+ :slug,
46
+ :title,
47
+ :body
48
+ )
49
+ end
50
+
51
+ alias_method :page_update_params, :page_create_params
52
+ end