checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 8d61798761b8eb2e9d40f36b901591187f6e163bdcb55cb392c4c8ee7264ad49
4
- data.tar.gz: '0099511f6bf24b4ade26941de89c78c77e4b454e8f8a5d87466373d7544c9aa5'
3
+ metadata.gz: c36c2e3ebcb7e12715bb81b07ba9d03e5e1541d73e6ae13b325f1ca74f033d45
4
+ data.tar.gz: 98c5ad8023241d0c7fd22598c4336b7eb04ccf675e163070ce0c217f2fc5d529
5
5
SHA512:
6
- metadata.gz: 4d9205edff9a20d9f91bc774ac9eb11f6c074955d3a153f3e54c5a18294132ed400fa0b4a9d7f73f43444690ec11ad585e05fd15270fdfe274088eb05fe66c65
7
- data.tar.gz: 100d1fbfd376cceb7e5dcd5b30828d55845933b7adc2ccd80cac681b3f16bf2cbb764de7d2a0f4b89274c4340da41683a9917342108144d8011b850395b5f962
6
+ metadata.gz: e2ad182abd2cf4918e4cffdb92b2947435d5e08892dc58a0689505aadbab43b3b17dcb4d36fb5f797ebe1ef591ddc70785f711b17b835bc7462ac1137d952a01
7
+ data.tar.gz: f5f0130a8ade749897c69496fa2075afb9295df24b251978675482eeaca2df4442bb32d44d3db365335ce91974b1be2669c4606433d7e09ab91cc449105054b9
data/lib/iatelier.rb CHANGED
@@ -17,7 +17,18 @@ require 'iatelier/models/application_record'
17
17
Gem.find_files('iatelier/models/*.rb').each {|file| require file }
18
18
Gem.find_files('iatelier/models/dimensions/*.rb').each {|file| require file }
19
19
20
+ require 'iatelier/configuration'
21
+
20
22
module Iatelier
23
+ class << self
24
+ attr_accessor :configuration
25
+ end
26
+
27
+ def self.configure
28
+ self.configuration ||= Configuration.new
29
+ yield(configuration)
30
+ end
31
+
21
32
class Application < Hanami::Application
22
33
configure do
23
34
##
data/lib/iatelier/configuration.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Iatelier
2
+ class Configuration
3
+ attr_accessor :atelier_name, :atelier_url, :storage_dir
4
+ def initialize
5
+ @atelier_name = nil
6
+ @atelier_url = nil
7
+ @storage_dir = './storage/books/'
8
+ end
9
+ end
10
+ end
data/lib/iatelier/models/book.rb CHANGED
@@ -38,14 +38,14 @@ class Book < ActiveRecord::Base
38
38
end
39
39
40
40
def content
41
- puts "we are here"
41
+ puts 'trying to open content'
42
42
unless self.id.nil?
43
-
44
- @storage_location = './storage/books/' + self.class.name.pluralize(2) + '/' + self.id.to_s + '/main.md'
45
- puts "now wer are going here :: " + @storage_location
46
- if File.exists? @storage_location
47
- puts "contnet is equal " + @@content
48
- @@content = File.open(@storage_location).read
43
+ puts 'id passed'
44
+ path = Iatelier.configuration.storage_dir + self.class.name.downcase + '/' + self.id.to_s + '/main.md'
45
+ puts 'path is set to ' + path
46
+ if File.exists? path
47
+ puts 'reading content'
48
+ @@content = File.open(path).read
49
49
else
50
50
@@content = nil
51
51
end
@@ -58,12 +58,6 @@ class Book < ActiveRecord::Base
58
58
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
59
59
markdown.render(self.content)
60
60
end
61
-
62
- def write_content text
63
- # if File.open(@storage_location).write
64
- # self.loc = self.id
65
- # self.save
66
- end
67
61
68
62
# def initialized
69
63
# super()
@@ -83,6 +77,7 @@ class Book < ActiveRecord::Base
83
77
self.save
84
78
sync_keywords params
85
79
sync_individuals params
80
+ sync_content params
86
81
end
87
82
88
83
def revise params
@@ -99,6 +94,7 @@ class Book < ActiveRecord::Base
99
94
end
100
95
sync_keywords params
101
96
sync_individuals params
97
+ sync_content params
102
98
end
103
99
104
100
def sync_keywords params
@@ -161,13 +157,26 @@ class Book < ActiveRecord::Base
161
157
self.build_title({value: params[:title]})
162
158
end
163
159
def revise_title params
164
- self.title.update_attributes({value: params[:title]})
160
+ self.title.update(value: params[:title])
165
161
end
166
162
167
163
def setup_slug params
168
164
self.build_slug({value: params[:slug]})
169
165
end
170
166
def revise_slug params
171
- self.slug.update_attributes({value: params[:slug]})
167
+ self.slug.update(value: params[:slug])
168
+ end
169
+
170
+ def sync_content params
171
+ puts 'we are trying to sync the content = ' + params[:content]
172
+ path = Iatelier.configuration.storage_dir + self.class.name.downcase + '/' + self.id.to_s
173
+ Dir.mkdir(path) unless File.exists?(path)
174
+ File.open(path + '/main.md', 'w+') do |file|
175
+ file.puts params[:content]
176
+ end
177
+ puts 'updating loc!!! ' + self.id.to_s
178
+ self.update(loc: self.id.to_s)
179
+ self.save
180
+ puts self.loc.to_s
172
181
end
173
- end
182
+ end
data/lib/iatelier/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module Iatelier
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: iatelier
3
3
version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
platform: ruby
6
6
authors:
7
7
- Captain Husayn Pinguin
@@ -179,6 +179,7 @@ files:
179
179
- lib/iatelier/assets/stylesheets/iatelier.css
180
180
- lib/iatelier/assets/stylesheets/selectize.css
181
181
- lib/iatelier/config/routes.rb
182
+ - lib/iatelier/configuration.rb
182
183
- lib/iatelier/controllers/.gitkeep
183
184
- lib/iatelier/controllers/books/create.rb
184
185
- lib/iatelier/controllers/books/edit.rb