photish 0.3.11 → 0.4.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 +4 -4
- data/.pryrc +2 -0
- data/README.md +73 -12
- data/TODO.md +8 -8
- data/bin/console +2 -10
- data/bin/setup +0 -2
- data/lib/photish/assets/example/photos/Big Dogs/Custom Template Page.slim +5 -0
- data/lib/photish/assets/example/site/_plugins/footer_links.rb +2 -1
- data/lib/photish/assets/example/site/_plugins/tmpdir_deploy.rb +2 -2
- data/lib/photish/assets/example/site/_plugins/yell_loud.rb +2 -1
- data/lib/photish/assets/example/site/_templates/album.slim +4 -0
- data/lib/photish/cache/db_file.rb +40 -0
- data/lib/photish/cache/manifest.rb +20 -18
- data/lib/photish/cache/repository.rb +42 -0
- data/lib/photish/cli/interface.rb +4 -0
- data/lib/photish/command/base.rb +6 -2
- data/lib/photish/command/deploy.rb +4 -8
- data/lib/photish/command/generate.rb +10 -26
- data/lib/photish/command/host.rb +8 -7
- data/lib/photish/command/init.rb +1 -1
- data/lib/photish/command/worker.rb +5 -17
- data/lib/photish/config/default_config.rb +5 -3
- data/lib/photish/config/file_config.rb +19 -5
- data/lib/photish/config/settings.rb +59 -0
- data/lib/photish/gallery/album.rb +27 -14
- data/lib/photish/gallery/collection.rb +27 -13
- data/lib/photish/gallery/image.rb +5 -12
- data/lib/photish/gallery/page.rb +40 -0
- data/lib/photish/gallery/photo.rb +7 -10
- data/lib/photish/gallery/traits/albumable.rb +9 -3
- data/lib/photish/gallery/traits/fileable.rb +30 -0
- data/lib/photish/gallery/traits/urlable.rb +12 -7
- data/lib/photish/log/io.rb +20 -0
- data/lib/photish/log/loggable.rb +1 -1
- data/lib/photish/log/{log_setup.rb → setup.rb} +1 -1
- data/lib/photish/{gallery/traits/breadcrumbable.rb → plugin/core/breadcrumb.rb} +12 -3
- data/lib/photish/plugin/core/build_url.rb +26 -0
- data/lib/photish/plugin/core/exifable.rb +15 -0
- data/lib/photish/plugin/core/metadatable.rb +27 -0
- data/lib/photish/plugin/repository.rb +3 -7
- data/lib/photish/plugin/type.rb +1 -0
- data/lib/photish/render/{image_conversion.rb → image.rb} +34 -18
- data/lib/photish/render/{site_worker.rb → model.rb} +13 -12
- data/lib/photish/render/page.rb +13 -24
- data/lib/photish/render/site.rb +3 -3
- data/lib/photish/render/template.rb +59 -0
- data/lib/photish/version.rb +1 -1
- data/lib/photish.rb +14 -11
- data/photish.gemspec +1 -0
- metadata +32 -14
- data/lib/photish/cache/manifest_db_file.rb +0 -36
- data/lib/photish/config/app_settings.rb +0 -57
- data/lib/photish/config/file_config_location.rb +0 -27
- data/lib/photish/config/image_extension.rb +0 -8
- data/lib/photish/core_plugin/breadcrumb.rb +0 -35
- data/lib/photish/core_plugin/build_url.rb +0 -20
- data/lib/photish/gallery/traits/metadatable.rb +0 -30
- data/lib/photish/log/access_log.rb +0 -11
data/lib/photish/command/host.rb
CHANGED
@@ -2,8 +2,8 @@ module Photish
|
|
2
2
|
module Command
|
3
3
|
class Host < Base
|
4
4
|
def run
|
5
|
-
log.
|
6
|
-
log.
|
5
|
+
log.debug "Site will be running at http://0.0.0.0:#{port}/"
|
6
|
+
log.debug "Monitoring paths #{paths_to_monitor}"
|
7
7
|
|
8
8
|
regenerate_entire_site
|
9
9
|
regenerate_thread
|
@@ -23,7 +23,7 @@ module Photish
|
|
23
23
|
trap 'INT' do server.shutdown end
|
24
24
|
listener.start
|
25
25
|
server.start
|
26
|
-
log.
|
26
|
+
log.debug "Photish host has shutdown"
|
27
27
|
ensure
|
28
28
|
regenerate_thread.exit if @regenerate_thread
|
29
29
|
listener.stop if @listener
|
@@ -62,7 +62,7 @@ module Photish
|
|
62
62
|
|
63
63
|
def handle_change(mod, add, del)
|
64
64
|
changes = changes_as_hash(mod, add, del)
|
65
|
-
log.
|
65
|
+
log.debug "File change detected: #{changes}}"
|
66
66
|
queue.push(changes)
|
67
67
|
end
|
68
68
|
|
@@ -79,19 +79,20 @@ module Photish
|
|
79
79
|
|
80
80
|
def access_log
|
81
81
|
[
|
82
|
-
[Photish::Log::
|
82
|
+
[Photish::Log::IO.new(log, :debug),
|
83
83
|
WEBrick::AccessLog::COMBINED_LOG_FORMAT]
|
84
84
|
]
|
85
85
|
end
|
86
86
|
|
87
87
|
def regenerate_entire_site
|
88
|
-
log.
|
88
|
+
log.debug "Regenerating site"
|
89
89
|
Photish::Command::Generate.new(regenerate_runtime_config)
|
90
90
|
.execute
|
91
91
|
end
|
92
92
|
|
93
93
|
def regenerate_runtime_config
|
94
|
-
runtime_config.merge(url: { type: 'absolute_relative' }
|
94
|
+
runtime_config.merge(url: { type: 'absolute_relative' },
|
95
|
+
soft_failure: true)
|
95
96
|
end
|
96
97
|
|
97
98
|
def queue
|
data/lib/photish/command/init.rb
CHANGED
@@ -2,12 +2,12 @@ module Photish
|
|
2
2
|
module Command
|
3
3
|
class Worker < Base
|
4
4
|
def run
|
5
|
-
log.
|
5
|
+
log.debug "Worker ##{worker_index} starting"
|
6
6
|
|
7
7
|
load_all_plugins
|
8
8
|
render_whole_site
|
9
9
|
|
10
|
-
log.
|
10
|
+
log.debug "Site generation completed, by Worker ##{worker_index}"
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
@@ -21,25 +21,13 @@ module Photish
|
|
21
21
|
:image_extensions,
|
22
22
|
to: :config
|
23
23
|
|
24
|
-
def load_all_plugins
|
25
|
-
return if Plugin::Repository.instance.loaded?
|
26
|
-
Plugin::Repository.instance.reload(config)
|
27
|
-
end
|
28
|
-
|
29
24
|
def render_whole_site
|
30
|
-
Render::
|
31
|
-
|
25
|
+
Render::Model.new(config, version_hash)
|
26
|
+
.all_for(collection)
|
32
27
|
end
|
33
28
|
|
34
29
|
def collection
|
35
|
-
@collection ||= Gallery::Collection.new(
|
36
|
-
qualities_mapped,
|
37
|
-
url,
|
38
|
-
image_extensions)
|
39
|
-
end
|
40
|
-
|
41
|
-
def qualities_mapped
|
42
|
-
qualities.map { |quality| OpenStruct.new(quality) }
|
30
|
+
@collection ||= Gallery::Collection.new(config)
|
43
31
|
end
|
44
32
|
end
|
45
33
|
end
|
@@ -17,14 +17,16 @@ module Photish
|
|
17
17
|
logging: logging,
|
18
18
|
url: url,
|
19
19
|
plugins: [],
|
20
|
-
image_extensions: image_extensions
|
20
|
+
image_extensions: image_extensions,
|
21
|
+
page_extension: 'slim',
|
22
|
+
soft_failure: false
|
21
23
|
}
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
28
|
def image_extensions
|
27
|
-
|
29
|
+
['aai', 'art', 'avs', 'bgr', 'bgra', 'bgro', 'bmp', 'bmp2', 'bmp3', 'brf', 'cal', 'cals', 'canvas', 'caption', 'cin', 'cip', 'clip', 'cmyk', 'cmyka', 'cur', 'cut', 'data', 'dcm', 'dcx', 'dds', 'dfont', 'dpx', 'dxt1', 'dxt5', 'eps2', 'eps3', 'fax', 'fits', 'fractal', 'fts', 'g3', 'gif', 'gif87', 'gradient', 'gray', 'group4', 'h', 'hald', 'hdr', 'histogram', 'hrz', 'htm', 'html', 'icb', 'ico', 'icon', 'inline', 'ipl', 'isobrl', 'isobrl6', 'jng', 'jnx', 'jpe', 'jpeg', 'jpg', 'jps', 'label', 'mac', 'magick', 'map', 'mask', 'matte', 'miff', 'mng', 'mono', 'mpc', 'msl', 'mtv', 'mvg', 'null', 'otb', 'otf', 'pal', 'palm', 'pam', 'pango', 'pattern', 'pbm', 'pcd', 'pcds', 'pct', 'pcx', 'pdb', 'pes', 'pfa', 'pfb', 'pfm', 'pgm', 'picon', 'pict', 'pix', 'pjpeg', 'plasma', 'png', 'png00', 'png24', 'png32', 'png48', 'png64', 'png8', 'pnm', 'ppm', 'preview', 'ps2', 'ps3', 'psb', 'psd', 'ptif', 'pwp', 'radial-gradient', 'ras', 'rgb', 'rgba', 'rgbo', 'rgf', 'rla', 'rle', 'scr', 'sct', 'sfw', 'sgi', 'shtml', 'six', 'sixel', 'sparse-color', 'stegano', 'sun', 'text', 'tga', 'thumbnail', 'tiff', 'tiff64', 'tile', 'tim', 'ttc', 'ttf', 'ubrl', 'ubrl6', 'uil', 'uyvy', 'vda', 'vicar', 'vid', 'viff', 'vips', 'vst', 'wbmp', 'wpg', 'xbm', 'xc', 'xcf', 'xpm', 'xv', 'ycbcr', 'ycbcra', 'yuv']
|
28
30
|
end
|
29
31
|
|
30
32
|
def url
|
@@ -39,7 +41,7 @@ module Photish
|
|
39
41
|
{
|
40
42
|
colorize: true,
|
41
43
|
output: ['stdout', 'file'],
|
42
|
-
level: '
|
44
|
+
level: 'debug'
|
43
45
|
}
|
44
46
|
end
|
45
47
|
|
@@ -1,18 +1,32 @@
|
|
1
1
|
module Photish
|
2
2
|
module Config
|
3
3
|
class FileConfig
|
4
|
-
|
5
|
-
|
4
|
+
FILE_NAME = 'config.yml'
|
5
|
+
|
6
|
+
def initialize(config_dir)
|
7
|
+
@config_dir = config_dir
|
6
8
|
end
|
7
9
|
|
8
10
|
def hash
|
9
|
-
return {} if !File.exist?(
|
10
|
-
YAML.load_file(
|
11
|
+
return {} if !File.exist?(path)
|
12
|
+
YAML.load_file(path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def path
|
16
|
+
File.join(directory, config_file_name)
|
11
17
|
end
|
12
18
|
|
13
19
|
private
|
14
20
|
|
15
|
-
attr_reader :
|
21
|
+
attr_reader :config_dir
|
22
|
+
|
23
|
+
def directory
|
24
|
+
config_dir || Dir.pwd
|
25
|
+
end
|
26
|
+
|
27
|
+
def config_file_name
|
28
|
+
FILE_NAME
|
29
|
+
end
|
16
30
|
end
|
17
31
|
end
|
18
32
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Photish
|
2
|
+
module Config
|
3
|
+
class Settings
|
4
|
+
def initialize(runtime_config)
|
5
|
+
@runtime_config = extract_config(runtime_config)
|
6
|
+
end
|
7
|
+
|
8
|
+
def config
|
9
|
+
@config ||= RecursiveOpenStruct.new(prioritized_config)
|
10
|
+
end
|
11
|
+
|
12
|
+
def version_hash
|
13
|
+
@version_hash ||= Digest::MD5.hexdigest(sensitive_config.to_json)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :runtime_config
|
19
|
+
|
20
|
+
def extract_config(hash)
|
21
|
+
{}.deep_merge(hash)
|
22
|
+
.deep_merge(JSON.parse(hash.fetch('config_override', '{}')))
|
23
|
+
.deep_symbolize_keys
|
24
|
+
end
|
25
|
+
|
26
|
+
def prioritized_config
|
27
|
+
@prioritized_config = {}.deep_merge(default_config)
|
28
|
+
.deep_merge(file_config)
|
29
|
+
.deep_merge(runtime_config)
|
30
|
+
.deep_merge(derived_config)
|
31
|
+
end
|
32
|
+
|
33
|
+
def sensitive_config
|
34
|
+
prioritized_config.slice(:qualities)
|
35
|
+
end
|
36
|
+
|
37
|
+
def derived_config
|
38
|
+
{
|
39
|
+
config_file_location: file_config_instance.path
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def file_config
|
44
|
+
file_config_instance.hash
|
45
|
+
.deep_symbolize_keys
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_config
|
49
|
+
DefaultConfig.new
|
50
|
+
.hash
|
51
|
+
.deep_symbolize_keys
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_config_instance
|
55
|
+
@file_config_instance ||= FileConfig.new(runtime_config[:config_dir])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -3,13 +3,15 @@ module Photish
|
|
3
3
|
class Album
|
4
4
|
include Traits::Urlable
|
5
5
|
include Traits::Albumable
|
6
|
-
include Traits::
|
7
|
-
include
|
6
|
+
include Traits::Fileable
|
7
|
+
include Plugin::Pluginable
|
8
8
|
|
9
9
|
delegate :qualities,
|
10
10
|
:image_extensions,
|
11
|
+
:page_extension,
|
11
12
|
:url_info,
|
12
|
-
to: :parent,
|
13
|
+
to: :parent,
|
14
|
+
allow_nil: true
|
13
15
|
|
14
16
|
def initialize(parent, path)
|
15
17
|
super
|
@@ -18,20 +20,21 @@ module Photish
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def name
|
21
|
-
@name ||=
|
23
|
+
@name ||= basename
|
22
24
|
end
|
23
25
|
|
24
26
|
def photos
|
25
|
-
@photos ||=
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
@photos ||= child_files.select { |file| image?(file) }
|
28
|
+
.map { |file| Photo.new(self, file) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def pages
|
32
|
+
@pages ||= child_files.select { |file| page?(file) }
|
33
|
+
.map { |file| Page.new(self, file) }
|
31
34
|
end
|
32
35
|
|
33
36
|
def plugin_type
|
34
|
-
|
37
|
+
Plugin::Type::Album
|
35
38
|
end
|
36
39
|
|
37
40
|
private
|
@@ -41,9 +44,19 @@ module Photish
|
|
41
44
|
|
42
45
|
alias_method :base_url_name, :name
|
43
46
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
+
def child_files
|
48
|
+
@child_files ||= Dir.entries(path)
|
49
|
+
.reject { |file| ['.', '..'].include?(file) }
|
50
|
+
.map { |file| File.join(path, file) }
|
51
|
+
.select { |file| File.file?(file) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def image?(file)
|
55
|
+
image_extensions.include?(extension_of(file))
|
56
|
+
end
|
57
|
+
|
58
|
+
def page?(file)
|
59
|
+
page_extension == extension_of(file)
|
47
60
|
end
|
48
61
|
|
49
62
|
def album_class
|
@@ -3,19 +3,18 @@ module Photish
|
|
3
3
|
class Collection
|
4
4
|
include Traits::Urlable
|
5
5
|
include Traits::Albumable
|
6
|
-
include Traits::
|
7
|
-
include
|
6
|
+
include Traits::Fileable
|
7
|
+
include Plugin::Pluginable
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
delegate :page_extension,
|
10
|
+
:photo_dir,
|
11
|
+
to: :config
|
12
12
|
|
13
|
-
|
13
|
+
alias_method :path, :photo_dir
|
14
|
+
|
15
|
+
def initialize(config)
|
14
16
|
super
|
15
|
-
@
|
16
|
-
@qualities = qualities
|
17
|
-
@url_info = url_info
|
18
|
-
@image_extensions = Set.new(image_extensions)
|
17
|
+
@config = config
|
19
18
|
end
|
20
19
|
|
21
20
|
def name
|
@@ -27,19 +26,34 @@ module Photish
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def plugin_type
|
30
|
-
|
29
|
+
Plugin::Type::Collection
|
31
30
|
end
|
32
31
|
|
33
32
|
def all_url_parts
|
34
33
|
@all_url_parts ||= [[url_parts],
|
35
34
|
all_albums.map(&:url_parts),
|
36
35
|
all_photos.map(&:url_parts),
|
37
|
-
all_images.map(&:url_parts)
|
36
|
+
all_images.map(&:url_parts),
|
37
|
+
all_pages.map(&:url_parts),
|
38
|
+
].flatten(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
def image_extensions
|
42
|
+
@image_extensions ||= Set.new(config.image_extensions)
|
43
|
+
end
|
44
|
+
|
45
|
+
def qualities
|
46
|
+
@qualities ||= config.qualities
|
47
|
+
.map { |quality| OpenStruct.new(quality) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def url_info
|
51
|
+
config.url
|
38
52
|
end
|
39
53
|
|
40
54
|
private
|
41
55
|
|
42
|
-
attr_reader :
|
56
|
+
attr_reader :config
|
43
57
|
|
44
58
|
def album_class
|
45
59
|
Album
|
@@ -2,7 +2,8 @@ module Photish
|
|
2
2
|
module Gallery
|
3
3
|
class Image
|
4
4
|
include Traits::Urlable
|
5
|
-
include
|
5
|
+
include Traits::Fileable
|
6
|
+
include Plugin::Pluginable
|
6
7
|
|
7
8
|
delegate :name,
|
8
9
|
:params,
|
@@ -21,11 +22,11 @@ module Photish
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def name
|
24
|
-
@name ||= "#{
|
25
|
+
@name ||= "#{basename_without_extension} #{quality_name}"
|
25
26
|
end
|
26
27
|
|
27
28
|
def plugin_type
|
28
|
-
|
29
|
+
Plugin::Type::Image
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
@@ -36,15 +37,7 @@ module Photish
|
|
36
37
|
alias_method :base_url_name, :name
|
37
38
|
|
38
39
|
def url_end
|
39
|
-
@url_end ||= "#{
|
40
|
-
end
|
41
|
-
|
42
|
-
def basename
|
43
|
-
@basename ||= File.basename(path, '.*')
|
44
|
-
end
|
45
|
-
|
46
|
-
def extension
|
47
|
-
@extentsion ||= File.extname(path)
|
40
|
+
@url_end ||= slugify("#{basename_without_extension}-#{quality_name}.#{extension}")
|
48
41
|
end
|
49
42
|
|
50
43
|
def base_url_name
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Photish
|
2
|
+
module Gallery
|
3
|
+
class Page
|
4
|
+
include Traits::Urlable
|
5
|
+
include Traits::Albumable
|
6
|
+
include Traits::Fileable
|
7
|
+
include Plugin::Pluginable
|
8
|
+
|
9
|
+
attr_reader :path
|
10
|
+
|
11
|
+
delegate :url_info,
|
12
|
+
to: :parent,
|
13
|
+
allow_nil: true
|
14
|
+
|
15
|
+
def initialize(parent, path)
|
16
|
+
super
|
17
|
+
@parent = parent
|
18
|
+
@path = path
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
@name ||= basename_without_extension
|
23
|
+
end
|
24
|
+
|
25
|
+
def plugin_type
|
26
|
+
Plugin::Type::Page
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :parent
|
32
|
+
|
33
|
+
alias_method :base_url_name, :name
|
34
|
+
|
35
|
+
def url_end
|
36
|
+
'index.html'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -2,12 +2,13 @@ module Photish
|
|
2
2
|
module Gallery
|
3
3
|
class Photo
|
4
4
|
include Traits::Urlable
|
5
|
-
include Traits::
|
6
|
-
include
|
5
|
+
include Traits::Fileable
|
6
|
+
include Plugin::Pluginable
|
7
7
|
|
8
8
|
delegate :qualities,
|
9
9
|
:url_info,
|
10
|
-
to: :parent,
|
10
|
+
to: :parent,
|
11
|
+
allow_nil: true
|
11
12
|
|
12
13
|
def initialize(parent, path)
|
13
14
|
super
|
@@ -16,19 +17,15 @@ module Photish
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def name
|
19
|
-
@name ||=
|
20
|
+
@name ||= basename_without_extension
|
20
21
|
end
|
21
22
|
|
22
23
|
def images
|
23
|
-
@images ||= qualities.map { |quality|
|
24
|
-
end
|
25
|
-
|
26
|
-
def exif
|
27
|
-
@exif ||= MiniExiftool.new(path)
|
24
|
+
@images ||= qualities.map { |quality| Image.new(self, path, quality) }
|
28
25
|
end
|
29
26
|
|
30
27
|
def plugin_type
|
31
|
-
|
28
|
+
Plugin::Type::Photo
|
32
29
|
end
|
33
30
|
|
34
31
|
private
|
@@ -4,9 +4,9 @@ module Photish
|
|
4
4
|
module Albumable
|
5
5
|
def albums
|
6
6
|
@albums ||= Dir.entries(path)
|
7
|
-
.reject { |file| ['.', '..'].include?(file)
|
8
|
-
.map { |file| File.join(path, file)
|
9
|
-
.reject { |file| !Dir.exist?(file)
|
7
|
+
.reject { |file| ['.', '..'].include?(file) }
|
8
|
+
.map { |file| File.join(path, file) }
|
9
|
+
.reject { |file| !Dir.exist?(file) }
|
10
10
|
.map { |file| album_class.new(self, file) }
|
11
11
|
end
|
12
12
|
|
@@ -21,6 +21,12 @@ module Photish
|
|
21
21
|
.flatten
|
22
22
|
end
|
23
23
|
|
24
|
+
def all_pages
|
25
|
+
@all_pages ||= all_albums.map(&:pages)
|
26
|
+
.concat(self.try(:pages) || [])
|
27
|
+
.flatten
|
28
|
+
end
|
29
|
+
|
24
30
|
def all_images
|
25
31
|
@all_images ||= all_photos.map(&:images)
|
26
32
|
.flatten
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Photish
|
2
|
+
module Gallery
|
3
|
+
module Traits
|
4
|
+
module Fileable
|
5
|
+
def extension_of(file)
|
6
|
+
File.extname(file)
|
7
|
+
.split('.')
|
8
|
+
.last
|
9
|
+
.try(:downcase)
|
10
|
+
end
|
11
|
+
|
12
|
+
def extension
|
13
|
+
extension_of(path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def dirname
|
17
|
+
File.dirname(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def basename
|
21
|
+
File.basename(path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def basename_without_extension
|
25
|
+
File.basename(path, '.*')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -15,21 +15,26 @@ module Photish
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def base_url_parts
|
18
|
-
@base_url_parts ||= parent.base_url_parts +
|
18
|
+
@base_url_parts ||= (parent.base_url_parts +
|
19
|
+
[slugify(base_url_name)]).compact
|
19
20
|
end
|
20
21
|
|
21
22
|
def host
|
22
|
-
@host ||=
|
23
|
-
url_info.host || ''
|
24
|
-
else
|
25
|
-
''
|
26
|
-
end
|
23
|
+
@host ||= absolute_uris? ? url_info_host : ''
|
27
24
|
end
|
28
25
|
|
29
26
|
private
|
30
27
|
|
31
28
|
def slugify(word)
|
32
|
-
CGI.escape(word.downcase.gsub(' ', '-'))
|
29
|
+
CGI.escape(word.downcase.gsub(' ', '-')) if word
|
30
|
+
end
|
31
|
+
|
32
|
+
def absolute_uris?
|
33
|
+
url_info.type == 'absolute_uri'
|
34
|
+
end
|
35
|
+
|
36
|
+
def url_info_host
|
37
|
+
url_info.host || ''
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Photish
|
2
|
+
module Log
|
3
|
+
class IO
|
4
|
+
def initialize(log, level)
|
5
|
+
@log = log
|
6
|
+
@level = level
|
7
|
+
end
|
8
|
+
|
9
|
+
def write(message)
|
10
|
+
log.send(level, message.chomp)
|
11
|
+
end
|
12
|
+
alias_method :<<, :write
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :log,
|
17
|
+
:level
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/photish/log/loggable.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
module Photish
|
2
|
-
module
|
3
|
-
module
|
4
|
-
module
|
2
|
+
module Plugin
|
3
|
+
module Core
|
4
|
+
module Breadcrumb
|
5
|
+
def self.is_for?(type)
|
6
|
+
[
|
7
|
+
Photish::Plugin::Type::Collection,
|
8
|
+
Photish::Plugin::Type::Album,
|
9
|
+
Photish::Plugin::Type::Photo,
|
10
|
+
Photish::Plugin::Type::Page,
|
11
|
+
].include?(type)
|
12
|
+
end
|
13
|
+
|
5
14
|
def breadcrumbs
|
6
15
|
html = "<ul class=\"breadcrumbs\">"
|
7
16
|
parents_and_me.each_with_index do |level, index|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Photish
|
2
|
+
module Plugin
|
3
|
+
module Core
|
4
|
+
module BuildUrl
|
5
|
+
def self.is_for?(type)
|
6
|
+
[
|
7
|
+
Photish::Plugin::Type::Collection,
|
8
|
+
Photish::Plugin::Type::Album,
|
9
|
+
Photish::Plugin::Type::Photo,
|
10
|
+
Photish::Plugin::Type::Page,
|
11
|
+
].include?(type)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_url(*pieces)
|
15
|
+
url_pieces = []
|
16
|
+
url_pieces << host
|
17
|
+
url_pieces << url_info.base
|
18
|
+
url_pieces << pieces
|
19
|
+
url_pieces.flatten
|
20
|
+
.compact
|
21
|
+
.join('/')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|