simplec 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f95b9fb5eef66eaf27ab18d642ee76f5ea67a547
4
- data.tar.gz: 05505f307bf86ffd6afd16545f5b6a5396a708da
3
+ metadata.gz: cc12728b3f36924c9748feeaf9b913adf6f2f4c5
4
+ data.tar.gz: acf72f1d1f5116208a044018df7e50ca298f458e
5
5
  SHA512:
6
- metadata.gz: c4cadd40978e45f0f20c8759226bef7ba6d6c2564de022ba589bfd36cf6af9a0520c40979b90c8aa9c764eb68113eaa7353e6da576a4f01bb70d7f291895325e
7
- data.tar.gz: 88d5a6034a54698c229887b0ab8165b5c6a0ef9fe309440a63895089cd53726cad136f8015173d597217154fab58d243a9f2b88dea95d35d62e9919dbe113156
6
+ metadata.gz: d7bd9cd9bc1007492113fc583e5c3eca2023938f6ab50f326e2f2ea194c946d24ec6bc5fe06aee34c88722f13ba8da53751282c8e233fb9e8fa21ea0ed190634
7
+ data.tar.gz: 0fb75e9fa2898854726b89dca64b5c3c610059835c5eecbf2dad81c53fd6aa3cd1a7f8e9071536b7edf59f8aa805ed57eec1644ec75d79bfde4833ab85a35b7f
data/README.md CHANGED
@@ -18,7 +18,8 @@ over the entire ecosystem.
18
18
 
19
19
  - imagemagick
20
20
 
21
- For image processing.
21
+ For image processing. Note there is a known vulnerability, please update
22
+ accordingly: https://imagetragick.com/
22
23
 
23
24
  - dragonfly
24
25
 
@@ -76,12 +77,6 @@ fallout. ;-)_
76
77
 
77
78
  ## Usage
78
79
 
79
- 1. Add to gemfile
80
- 2. Mount engine
81
- 3. Create pages and corresponding templates
82
- 4. Build, generator, or use an auxilary gem for page admin.
83
- 5. Let users loose.
84
-
85
80
  'www' is considered the default subdomain.
86
81
 
87
82
  'admin' subdomain is reserved for administration functions if you wish.
@@ -103,6 +98,8 @@ TODO override field types howto
103
98
 
104
99
  TODO explain using uuids for keys + pgcrypto
105
100
 
101
+ TODO explain how to augment model classes (example in `test/dummy/config/initializers/simplec.rb`)
102
+
106
103
  ### Steps
107
104
 
108
105
  1. Install simplec in your Rails application.
@@ -245,7 +242,25 @@ See this page for a good cheat sheet: http://markevans.github.io/dragonfly/image
245
242
 
246
243
  ## Roadmap
247
244
 
248
- 1. Finish example admin.
245
+ 1. TODOS:
246
+
247
+ - Embedded image id (integer -> uuid)
248
+
249
+ - Check doc view helpers
250
+
251
+ - Throw clear warning when creating a page without a type
252
+
253
+ - Document `lib/simplec/controller_extensions.rb`
254
+
255
+ - Document why _subdomain in subdomain form in admin.
256
+
257
+ - rails generate simplec:install
258
+ Install app/models/page.rb, app/models/page/
259
+ initializer if needed, with options documented
260
+
261
+ - rewrite beginning part of usage
262
+
263
+ - simplec_path/simplec_url caching
249
264
 
250
265
  1. Installer `rails generater simplec:install`
251
266
 
@@ -264,18 +279,6 @@ See this page for a good cheat sheet: http://markevans.github.io/dragonfly/image
264
279
  relegated to 3rd party extensions.
265
280
  2. Pull requests are welcome. See rule #1.
266
281
 
267
- ## TODO
268
-
269
- - Document `lib/simplec/controller_extensions.rb`
270
-
271
- - Document why _subdomain in subdomain form in admin.
272
-
273
- - rails generate simplec:install
274
- Install app/models/page.rb, app/models/page/
275
- initializer if needed, with options documented
276
-
277
- - simplec_path/simplec_url caching
278
-
279
282
  ## Running dummy application
280
283
 
281
284
  1. Create simplec postgres user
@@ -0,0 +1,37 @@
1
+ module Simplec
2
+ class Document < ApplicationRecord
3
+
4
+ belongs_to :document_set,
5
+ optional: true
6
+ has_and_belongs_to_many :subdomains
7
+
8
+ dragonfly_accessor :file
9
+
10
+ validates :name,
11
+ presence: true
12
+ validate :validate_subdomain_or_set!
13
+ validate :validate_slug!
14
+
15
+ def path
16
+ self.file.url
17
+ end
18
+
19
+ private
20
+
21
+ def validate_subdomain_or_set!
22
+ return if self.subdomains.length > 0
23
+ return if self.document_set
24
+ errors.add :subdomain_ids, 'either a document set or at least one subdomain is required'
25
+ end
26
+
27
+ def validate_slug!
28
+ similar = self.class.where(slug: self.slug).where.not(id: self.id)
29
+ return if similar.size == 0
30
+ return if (
31
+ similar.map(&:subdomain_ids).flatten & self.subdomain_ids
32
+ ).length == 0
33
+ errors.add :slug, 'slug must be unique across linked subdomains'
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ module Simplec
2
+ class DocumentSet < ApplicationRecord
3
+
4
+ has_many :documents
5
+ has_and_belongs_to_many :subdomains
6
+
7
+ validates :name,
8
+ presence: true
9
+ validate :validate_subdomain!
10
+ validate :validate_slug!
11
+
12
+ private
13
+
14
+ def validate_subdomain!
15
+ return if self.subdomains.length > 0
16
+ errors.add :subdomain_ids, 'at least one is required'
17
+ end
18
+
19
+ def validate_slug!
20
+ similar = self.class.where(slug: self.slug).where.not(id: self.id)
21
+ return if similar.size == 0
22
+ return if (
23
+ similar.map(&:subdomain_ids).flatten & self.subdomain_ids
24
+ ).length == 0
25
+ errors.add :slug, 'slug must be unique across linked subdomains'
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ class CreateSimplecDocuments < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :simplec_documents, id: :uuid, default: 'gen_random_uuid()' do |t|
4
+ t.uuid :document_set_id
5
+ t.string :slug
6
+ t.string :name
7
+ t.boolean :required, default: false
8
+ t.text :description
9
+ t.string :file_uid
10
+ t.string :file_name
11
+
12
+ t.timestamps
13
+ end
14
+ add_index :simplec_documents, :document_set_id
15
+ add_index :simplec_documents, :slug
16
+ add_index :simplec_documents, :name
17
+
18
+ create_table :simplec_documents_subdomains, index: false do |t|
19
+ t.uuid :document_id
20
+ t.uuid :subdomain_id
21
+ end
22
+ add_index :simplec_documents_subdomains, [:document_id, :subdomain_id],
23
+ unique: true,
24
+ name: 'index_simplec_documents_subdomains_unique'
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ class CreateSimplecDocumentSets < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :simplec_document_sets, id: :uuid, default: 'gen_random_uuid()' do |t|
4
+ t.string :slug
5
+ t.string :name
6
+ t.boolean :required, default: false
7
+ t.text :description
8
+
9
+ t.timestamps
10
+ end
11
+ add_index :simplec_document_sets, :slug
12
+ add_index :simplec_document_sets, :name
13
+
14
+ create_table :simplec_document_sets_subdomains, index: false do |t|
15
+ t.uuid :document_set_id
16
+ t.uuid :subdomain_id
17
+ end
18
+ add_index :simplec_document_sets_subdomains, [:document_set_id, :subdomain_id],
19
+ unique: true,
20
+ name: 'index_simplec_document_sets_subdomains_unique'
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Simplec
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -120,6 +120,8 @@ files:
120
120
  - app/jobs/simplec/application_job.rb
121
121
  - app/mailers/simplec/application_mailer.rb
122
122
  - app/models/simplec/application_record.rb
123
+ - app/models/simplec/document.rb
124
+ - app/models/simplec/document_set.rb
123
125
  - app/models/simplec/embedded_image.rb
124
126
  - app/models/simplec/page.rb
125
127
  - app/models/simplec/subdomain.rb
@@ -133,6 +135,8 @@ files:
133
135
  - db/migrate/20170809204353_create_simplec_pages.rb
134
136
  - db/migrate/20170809204511_create_simplec_subdomains.rb
135
137
  - db/migrate/20170809210304_create_simplec_embedded_images.rb
138
+ - db/migrate/20170814211816_create_simplec_documents.rb
139
+ - db/migrate/20170814211929_create_simplec_document_sets.rb
136
140
  - lib/simplec.rb
137
141
  - lib/simplec/action_controller/extensions.rb
138
142
  - lib/simplec/action_view/helper.rb