iatelier 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d0ea435d398836e042fdc16823794f774ead547af140dab422a08c6890142aa
4
- data.tar.gz: 746fb34460ec905ac5e505f770595124df7bc40b93f416658d43e47613e7dc9b
3
+ metadata.gz: 7197869b7483e6d3418708d5a73eb219b45ed27803263ade922666e3e15c48e0
4
+ data.tar.gz: ab05fd67450e3f3e939fc957a5a75ddafe2c0fc612eac2f91ca20a760f0d5264
5
5
  SHA512:
6
- metadata.gz: 82c1cefe9a016441ec0c243d62f5103a29cd65ae709ef822df9417c4b781f4e6cfed60cc19b97998889b9880a03944427c8a58f27039fe3af1fb480993c05b75
7
- data.tar.gz: fda655c5b7feb305f307d62335fb5c518de82ce57a8412d9bfe5c0faf833255a497eb4f3271436cd4c4c0a3209db45e9fc10c30eec57ff423dc6ddc3369061f6
6
+ metadata.gz: 7e6cc9a102be00f0299c158e55fd21ed2b2d385b4f0e7e2e25c0db90a6921809eda967b6a3c0a5a0fc39a69c3782932631dcf6f69b141b58d36d35985912d57c
7
+ data.tar.gz: 27f857f759065a3d1d17805c3a704c9b7b36adf59b92141d1605d6e77a2ebcfd468adf113fd67c4756881b89a9154276b15af062a7086fcdbc16345559b3763d
@@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "rspec", "~> 3.9"
41
41
  spec.add_development_dependency "hanami", "~> 1.3"
42
42
  spec.add_runtime_dependency "redcarpet", "~>3.5"
43
+ spec.add_runtime_dependency "mime-types", "~>3.3"
43
44
  end
@@ -4,10 +4,12 @@ module Iatelier
4
4
  module DbConnector
5
5
  def set_database database
6
6
  tmp_config = ActiveRecord::Base.connection_config
7
- tmp_config[:database] = database
8
- ActiveRecord::Base.establish_connection tmp_config
7
+ if !database.nil?
8
+ tmp_config[:database] = database
9
+ ActiveRecord::Base.establish_connection tmp_config
10
+ end
9
11
  end
10
12
  end
11
13
  end
12
14
  end
13
- end
15
+ end
@@ -4,11 +4,46 @@ module Iatelier
4
4
  class Create
5
5
  include Iatelier::Action
6
6
  include Iatelier::Controllers::Books::DbConnector
7
+ expose :book, :book_type, :database, :errors
7
8
  def call(params)
8
- self.set_database params[:database]
9
+ # [optional] setting the database
10
+ @database = params.get(:database)
11
+ self.set_database @database
12
+
13
+ #
9
14
  @book = Object.const_get(params[:book_type].capitalize).new
10
- @book.save
11
- @book.create(params)
15
+ @book.namespace = database
16
+
17
+ # p 'starting everything'
18
+ @book.dimensions.each do |dimension|
19
+ method_name = 'setup_' + dimension
20
+ action = @book.public_send(method_name.to_sym, params)
21
+ p 'what is the status = ' + action.valid?.to_s
22
+ if !action.valid?
23
+ puts 'the error is ' + action.errors.messages.to_s
24
+ @errors = action.errors.messages
25
+ self.status = 422
26
+ return 'caught an error!'
27
+ end
28
+ end
29
+
30
+ @book.save
31
+
32
+ @book.dimensions.each do |dimension|
33
+ action = @book.public_send(dimension.to_sym)
34
+ if !action.save
35
+ @errors = action.errors.messages
36
+ self.status = 422
37
+ return 'caught an error!'
38
+ end
39
+ end
40
+
41
+ @book.sync_keywords params
42
+ @book.sync_individuals params
43
+ @book.sync_content params
44
+ @book.store_attachment params
45
+
46
+ redirect_to '/iatelier/' + @database + '/' + params[:book_type]
12
47
  end
13
48
  end
14
49
  end
@@ -6,10 +6,13 @@ module Iatelier
6
6
  include Iatelier::Controllers::Books::DbConnector
7
7
  expose :book, :database
8
8
  def call(params)
9
- @database = params[:database]
10
- self.set_database database
9
+ # [optional] setting the database
10
+ @database = params.get(:database)
11
+ self.set_database @database
12
+
13
+ #
11
14
  @book = Object.const_get(params[:book_type].capitalize).find(params[:id])
12
- @book.namespace = Ilog.configuration.namespaces.key(@database)
15
+ @book.namespace = @database
13
16
  end
14
17
  end
15
18
  end
@@ -4,10 +4,17 @@ module Iatelier
4
4
  class Manage
5
5
  include Iatelier::Action
6
6
  include Iatelier::Controllers::Books::DbConnector
7
- expose :books
7
+ expose :books, :uri
8
8
  def call(params)
9
- self.set_database params[:database]
10
- @books = Object.const_get(params[:book_type].capitalize).all
9
+ # [optional] setting the database
10
+ @database = params.get(:database)
11
+ self.set_database @database
12
+
13
+ #
14
+ @books = Object.const_get(params[:book_type].capitalize).includes(:timestamp).all.order("timestamps.publish desc")
15
+
16
+ #
17
+ @uri = '/iatelier/' + @database + '/' + params[:book_type] + '/'
11
18
  end
12
19
  end
13
20
  end
@@ -6,8 +6,10 @@ module Iatelier
6
6
  include Iatelier::Controllers::Books::DbConnector
7
7
  expose :book, :book_type, :database
8
8
  def call(params)
9
- @database = params[:database]
10
- self.set_database database
9
+ # [optional] setting the database
10
+ @database = params.get(:database)
11
+ self.set_database @database
12
+
11
13
  @book_type = params[:book_type].capitalize;
12
14
  @book = Object.const_get(@book_type).new
13
15
  @book.namespace = @database
@@ -15,4 +17,4 @@ module Iatelier
15
17
  end
16
18
  end
17
19
  end
18
- end
20
+ end
@@ -4,14 +4,35 @@ module Iatelier
4
4
  class Update
5
5
  include Iatelier::Action
6
6
  include Iatelier::Controllers::Books::DbConnector
7
+ expose :book, :database, :errors
7
8
  def call(params)
8
- @database = params[:database]
9
+ # [optional] setting the database
10
+ @database = params.get(:database)
9
11
  self.set_database @database
12
+
13
+ # setting up the book
10
14
  @book = Object.const_get(params[:book_type].capitalize).find(params[:id])
11
- @book.namespace = Ilog.configuration.namespaces.key(@database)
12
- @book.revise(params)
13
- @book.save
14
- self.body = @book.save.to_json
15
+ @book.namespace = @database
16
+
17
+ @book.dimensions.each do |dimension|
18
+ if @book.public_send(dimension.to_sym)
19
+ method_name = 'revise_' + dimension
20
+ else
21
+ method_name = 'setup_' + dimension
22
+ end
23
+ @book.public_send(method_name.to_sym, params)
24
+ end
25
+ @book.dimensions.each do |dimension|
26
+ action = @book.public_send(dimension.to_sym)
27
+ if !action.save
28
+ @errors = action.errors.messages
29
+ self.status = 422
30
+ end
31
+ end
32
+ @book.sync_keywords params
33
+ @book.sync_individuals params
34
+ @book.sync_content params
35
+ @book.store_attachment params
15
36
  end
16
37
  end
17
38
  end
@@ -68,45 +68,6 @@ class Book < ActiveRecord::Base
68
68
  return markdown.render(content_raw.to_s)
69
69
  end
70
70
 
71
- # def initialized
72
- # super()
73
- # puts "content of the dimension: \n"
74
- # puts dimensions.inspect
75
- # dimensions.each do |dimension|
76
- # reference = dimension + able
77
- # hasone dimension.to_sym as: reference.to_sym
78
- # end
79
- # end
80
-
81
- def create params
82
- puts 'these are the stuff were going to add:' + dimensions.to_s
83
- dimensions.each do |dimension|
84
- method_name = 'setup_' + dimension
85
- self.public_send(method_name.to_sym, params)
86
- end
87
- self.save
88
- sync_keywords params
89
- sync_individuals params
90
- sync_content params
91
- end
92
-
93
- def revise params
94
- dimensions.each do |dimension|
95
- if self.public_send(dimension.to_sym)
96
- method_name = 'revise_' + dimension
97
- else
98
- method_name = 'setup_' + dimension
99
- end
100
- self.public_send(method_name.to_sym, params)
101
- end
102
- dimensions.each do |dimension|
103
- self.public_send(dimension.to_sym).save
104
- end
105
- sync_keywords params
106
- sync_individuals params
107
- sync_content params
108
- end
109
-
110
71
  def sync_keywords params
111
72
  @nkeys = []
112
73
  @keywords = params[:keywords].split ', '
@@ -164,24 +125,31 @@ class Book < ActiveRecord::Base
164
125
  end
165
126
 
166
127
  def setup_title params
167
- self.build_title({value: params[:title]})
128
+ return self.build_title({value: params[:title]})
168
129
  end
169
130
  def revise_title params
170
- self.title.update(value: params[:title])
131
+ return self.title.update(value: params[:title])
171
132
  end
172
133
 
173
134
  def setup_subtitle params
174
- self.build_subtitle({value: params[:subtitle]})
135
+ return self.build_subtitle({value: params[:subtitle]})
175
136
  end
176
137
  def revise_subtitle params
177
- self.subtitle.update(value: params[:subtitle])
138
+ return self.subtitle.update(value: params[:subtitle])
178
139
  end
179
140
 
180
141
  def setup_slug params
181
- self.build_slug({value: params[:slug]})
142
+ return self.build_slug({value: params[:slug]})
182
143
  end
183
144
  def revise_slug params
184
- self.slug.update(value: params[:slug])
145
+ return self.slug.update(value: params[:slug])
146
+ end
147
+
148
+ def setup_description params
149
+ self.build_description({value: params[:description]})
150
+ end
151
+ def revise_description params
152
+ self.description.update(value: params[:description])
185
153
  end
186
154
 
187
155
  def setup_thumbnail params
@@ -223,4 +191,18 @@ class Book < ActiveRecord::Base
223
191
  self.save
224
192
  puts self.loc.to_s
225
193
  end
194
+
195
+ def store_attachment params
196
+ path = Iatelier.configuration.storage_dir + @namespace.to_s + self.class.name.downcase + '/' + self.id.to_s + '/'
197
+ if !params.get(:file).nil?
198
+ Dir.mkdir(path) unless File.exists?(path)
199
+ File.open(path + params[:file][:filename], 'wb') do |file|
200
+ file.write params[:file][:tempfile].read
201
+ end
202
+ end
203
+ end
204
+ def get_asset params
205
+ path = Iatelier.configuration.storage_dir + @namespace.to_s + self.class.name.downcase + '/' + self.id.to_s + '/'
206
+ return File.open(path + params[:asset], 'r')
207
+ end
226
208
  end
@@ -1,4 +1,10 @@
1
1
  .panel-edit
2
+ - if @locals.include?(:errors)
3
+ .form-box
4
+ .os-form-group
5
+ - errors.each do |value, key|
6
+ %p= value
7
+ %p= key
2
8
  .form-box
3
9
  .os-form-group
4
10
  -if book.dimensions.include? 'title'
@@ -16,6 +22,9 @@
16
22
  -if book.dimensions.include? 'description'
17
23
  %label.label Description
18
24
  %input{:class => "form-control pure-input-1", :name => "description", :type => "text", :placeholder => "Description", :value => book.description.try(:value)}
25
+ .os-form-group
26
+ %label.label Attachments
27
+ %input{:type => 'file', :id => 'file', :name => 'file'}
19
28
  .form-box
20
29
  %label Text
21
30
  %br
@@ -31,4 +40,3 @@
31
40
  = render :partial => 'grouping/bundles'
32
41
  .form-box
33
42
  = render :partial => 'dimension/timestamp'
34
-
@@ -1,5 +1,4 @@
1
1
  %div
2
- .todo adding errors here!
3
2
  %form{:class => "atelier-main-form pure-form pure-form-aligned", :action => "/iatelier/#{database}/#{book.class.name.downcase}/#{book.id}", :method => "POST", :enctype => "multipart/form-data"}
4
3
  .form-actions
5
4
  <button type="submit" class="btn btn-default">Edit</button>
@@ -8,5 +8,7 @@
8
8
  - books.each do |book|
9
9
  %tr
10
10
  %td= book.id
11
- %td= book.title.value
11
+ %td
12
+ %a{href: uri + book.id.to_s + '/edit' }
13
+ = book.title.value
12
14
  %td= book.slug.try(:value)
@@ -1,6 +1,5 @@
1
1
  %div
2
- .todo adding errors here!
3
2
  %form{:class => "atelier-main-form pure-form pure-form-aligned", :action => "/iatelier/#{database}/#{book.class.name.downcase}/#{book.id}", :method => "POST", :enctype => "multipart/form-data"}
4
3
  .form-actions
5
4
  <button type="submit" class="btn btn-default">Create</button>
6
- = render :partial => 'engine'
5
+ = render :partial => 'engine'
@@ -1,3 +1,3 @@
1
1
  module Iatelier
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -3,6 +3,7 @@ module Iatelier
3
3
  module Books
4
4
  class Create
5
5
  include Iatelier::View
6
+ template 'books/new'
6
7
  end
7
8
  end
8
9
  end
@@ -3,6 +3,9 @@ module Iatelier
3
3
  module Books
4
4
  class Manage
5
5
  include Iatelier::View
6
+ def uri
7
+ raw locals[:uri]
8
+ end
6
9
  end
7
10
  end
8
11
  end
@@ -3,6 +3,7 @@ module Iatelier
3
3
  module Books
4
4
  class Update
5
5
  include Iatelier::View
6
+ template 'books/edit'
6
7
  end
7
8
  end
8
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iatelier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Captain Husayn Pinguin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-30 00:00:00.000000000 Z
11
+ date: 2020-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mime-types
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.3'
83
97
  description: iAtelier, a simple, yet powerful CMS engine for Hanami
84
98
  email:
85
99
  - captainhusaynpinguin@galacticvisions.xyz
@@ -141,7 +155,6 @@ files:
141
155
  - lib/iatelier/templates/books/grouping/_peoples.html.haml
142
156
  - lib/iatelier/templates/books/manage.html.haml
143
157
  - lib/iatelier/templates/books/new.html.haml
144
- - lib/iatelier/templates/books/update.html.haml
145
158
  - lib/iatelier/version.rb
146
159
  - lib/iatelier/views/application_layout.rb
147
160
  - lib/iatelier/views/books/create.rb