jekyll-smugmug 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e080d55e641f1e56758a4effd591631440456d85
4
+ data.tar.gz: 1373080708a4acaa02313802d54444f21553d315
5
+ SHA512:
6
+ metadata.gz: 133c139f7e4d1691ae19798c31b8232d05ffcb2a59df8e8627d9363ce7c27d63218f470b6040c8b2fa064b0bb1ecbc91ad94bda2a0f8886b63a067ac6cea6ab2
7
+ data.tar.gz: 1be3ffbcd4f9f845d2309d0214dd93c66fb9a130799c3562a2901bc70c9fd4f6c83571ec9b9a7d97bbbe758b1902de6e6d6efd41c69fa687a7a3a02ba364d59d
@@ -0,0 +1,8 @@
1
+ require 'jekyll'
2
+ require 'liquid'
3
+ require 'jekyll-smugmug/smugmug'
4
+ require 'jekyll-smugmug/smugmug_img'
5
+ require 'jekyll-smugmug/smugmug_url'
6
+
7
+ Liquid::Template.register_tag('smugmug', Jekyll::SmugmugImgTag)
8
+ Liquid::Template.register_tag('smugmug_url', Jekyll::SmugmugUrlTag)
@@ -0,0 +1,22 @@
1
+ require 'smugimg'
2
+
3
+ module Jekyll
4
+ class SmugmugTag < Liquid::Tag
5
+ DimensionsFormat = /([0-9]+x[0-9]+|Ti|Th|S|M|L|XL|X2|X3|O)/
6
+
7
+ def initialize(tag_name, markup, tokens)
8
+ super
9
+
10
+ @attrib = {}
11
+ markup.scan(Liquid::TagAttributes) do |key, value|
12
+ @attrib[key] = value
13
+ end
14
+ end
15
+
16
+ protected
17
+
18
+ def resized_url(guid, size)
19
+ SmugImg::Image.new(guid).at_size(size)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module Jekyll
2
+ class SmugmugImgTag < SmugmugTag
3
+ SmugmugSyntax = "smugmug dimensions: [width]x[height] guid: [url]"
4
+ DefaultAltText = "The photograph"
5
+
6
+ def initialize(tag_name, markup, tokens)
7
+ super
8
+
9
+ unless @attrib["dimensions"] and @attrib["dimensions"] =~ DimensionsFormat
10
+ raise SyntaxError.new("Syntax error in 'smugmug' - Valid syntax: #{SmugmugSyntax}")
11
+ end
12
+
13
+ unless @attrib["alt"]
14
+ @attrib["alt"] = DefaultAltText
15
+ end
16
+ end
17
+
18
+ def render(context)
19
+ guid = context.has_key?(@attrib['guid']) ? context[@attrib['guid']] : @attrib['guid']
20
+ url = resized_url(guid, @attrib["dimensions"])
21
+ alt = context[@attrib["alt"]]
22
+ return %Q(<img src="#{url}" alt="#{alt}" class="smphoto" />)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module Jekyll
2
+ class SmugmugUrlTag < SmugmugTag
3
+ SmugmugSyntax = "smugmug_url dimensions: [width]x[height] guid: [url]"
4
+
5
+ def initialize(tag_name, markup, tokens)
6
+ super
7
+
8
+ unless @attrib["dimensions"] and @attrib["dimensions"] =~ DimensionsFormat
9
+ raise SyntaxError.new("Syntax error in 'smugmug_url' - Valid syntax: #{SmugmugSyntax}")
10
+ end
11
+ end
12
+
13
+ def render(context)
14
+ guid = context.has_key?(@attrib['guid']) ? context[@attrib['guid']] : @attrib['guid']
15
+ resized_url(guid, @attrib["dimensions"])
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-smugmug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tom Harrison
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ description: jekyll-smugmug is a plugin which creates custom Liquid tags so that you
42
+ can easily generate URLs and IMG tags to SmugMug photos in your Jekyll-powered site.
43
+ email: tomharrison@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/jekyll-smugmug.rb
49
+ - lib/jekyll-smugmug/smugmug.rb
50
+ - lib/jekyll-smugmug/smugmug_img.rb
51
+ - lib/jekyll-smugmug/smugmug_url.rb
52
+ homepage: https://github.com/tomharrison/jekyll-smugmug
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.2.2
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Liquid tags for displaying SmugMug photos on a Jekyll site
76
+ test_files: []