checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: c8952177f82a1315b768fa9f1bef0aea0af51ccfe3116abe374558465b22a10f
4
- data.tar.gz: 22493c9640bfb7204ef9da715a45f5f41f71bc94197a71b954f7a61694f4cda0
3
+ metadata.gz: c36c2e3ebcb7e12715bb81b07ba9d03e5e1541d73e6ae13b325f1ca74f033d45
4
+ data.tar.gz: 98c5ad8023241d0c7fd22598c4336b7eb04ccf675e163070ce0c217f2fc5d529
5
5
SHA512:
6
- metadata.gz: 38d82e74a912179ce5eae4d4e21028000066d6e7bf7542f0dff85b1d5087064897eb68fc20292cd5b43659ecf190beacfeae699f6cc2148bd9aec208a0403e90
7
- data.tar.gz: 03f085257ca2361694d019a509142d54526530e206872f56b62ec92c41d8c5cbc791fb4f073ddfd45c388def6ff9e462254e799aa3d3c66c9b28a94f481d93d9
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
##
@@ -27,7 +38,7 @@ module Iatelier
27
38
# Define the root path of this application.
28
39
# All paths specified in this configuration are relative to path below.
29
40
#
30
- root File.dirname __dir__
41
+ root __dir__
31
42
32
43
# Relative load paths where this application will recursively load the
33
44
# code.
data/lib/iatelier/config/routes.rb CHANGED
@@ -3,12 +3,10 @@
3
3
#
4
4
# Example:
5
5
6
- namespace 'iatelier/analog' do
6
+ namespace 'analog' do
7
7
get '/:book_type', to: 'books#manage'
8
8
get '/:book_type/new', to: 'books#new'
9
9
post '/:book_type', to: 'books#create'
10
10
get '/:book_type/:id/edit', to: 'books#edit'
11
11
patch '/:book_type/:id', to: 'books#update'
12
- end
12
+ end
13
-
14
- get '/*', to: Iatelier::Controllers::Ileaf
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.11"
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.11
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