placepic 0.1.11 → 0.1.13
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/.gitignore +1 -0
- data/Gemfile +14 -1
- data/README.md +93 -6
- data/Rakefile +4 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/test_controller.rb +6 -0
- data/app/views/layouts/application.html.erb +22 -0
- data/app/views/test/show.html.slim +68 -0
- data/bin/bundle +3 -0
- data/bin/rails +8 -0
- data/bin/rake +8 -0
- data/bin/setup +27 -5
- data/bin/spring +15 -0
- data/config.ru +4 -0
- data/config/application.rb +15 -0
- data/config/boot.rb +3 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +38 -0
- data/config/environments/test.rb +42 -0
- data/config/initializers/assets.rb +11 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +5 -0
- data/config/secrets.yml +22 -0
- data/lib/placepic/placeholders.rb +20 -7
- data/lib/placepic/urls.rb +4 -9
- data/lib/placepic/version.rb +1 -1
- data/placepic.gemspec +2 -2
- data/public/404.html +67 -0
- data/public/422.html +67 -0
- data/public/500.html +66 -0
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84baee86a7502766c0fbbd0b7a4b6692857aaa04
|
4
|
+
data.tar.gz: 14f9705faee7acac09f7473409f46b32956835f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e390122e6b7c681ac7077c065914fa13ae6337df4a59e8350d12f01601153ce5b55b5c4bf6aa0072791617d7d15dbfef870dac731e9e56959813aafccb9e40
|
7
|
+
data.tar.gz: 627cc60307b96de9fc38bb282a4c62a0afb504abebc40ee04600926f165986fce13502df63bfcd422e91b261e2f1d25f2a7912331ee021bff7af982979b2554c
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in placepic.gemspec
|
4
3
|
gemspec
|
4
|
+
gem 'rails', '4.2.4'
|
5
|
+
gem "slim-rails"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'byebug'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :development do
|
12
|
+
gem "better_errors"
|
13
|
+
gem "binding_of_caller"
|
14
|
+
gem 'web-console', '~> 2.0'
|
15
|
+
gem 'spring'
|
16
|
+
end
|
17
|
+
|
data/README.md
CHANGED
@@ -1,8 +1,43 @@
|
|
1
1
|
# PlacePic
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/placepic)
|
4
4
|
|
5
|
-
|
5
|
+
PlacePic generates placeholder image tags and image urls for use whilst developing rails websites.
|
6
|
+
|
7
|
+
# Quickstart
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
placeholder_url
|
11
|
+
placeholder_url(width)
|
12
|
+
placeholder_url(width, height)
|
13
|
+
placeholder_url(width, height, site: site_name)
|
14
|
+
placeholder_url(width, height, style: style_code)
|
15
|
+
placeholder_url(width, height, site: site_name, style: style_code)
|
16
|
+
placeholder_tag
|
17
|
+
placeholder_tag(width)
|
18
|
+
placeholder_tag(width, height)
|
19
|
+
placeholder_tag(width, height, site: site_name)
|
20
|
+
placeholder_tag(width, height, style: style_code)
|
21
|
+
placeholder_tag(width, height, site: site_name, style: style_code)
|
22
|
+
```
|
23
|
+
|
24
|
+
####Options
|
25
|
+
|
26
|
+
| site | styles |
|
27
|
+
| --------------- | -------------------- |
|
28
|
+
| placebear | '', 'g', |
|
29
|
+
| stevensegallery | '', 'g', |
|
30
|
+
| fillmurray | '', 'g', |
|
31
|
+
| placecage | '', 'g', 'c', 'gif' |
|
32
|
+
| lorempixel | '', 'g', |
|
33
|
+
|
34
|
+
# Image Sources
|
35
|
+
|
36
|
+
* placebear.com
|
37
|
+
* stevensegallery.com
|
38
|
+
* fillmurray.com
|
39
|
+
* placecage.com
|
40
|
+
* lorempixel.com
|
6
41
|
|
7
42
|
## Installation
|
8
43
|
|
@@ -22,17 +57,69 @@ Or install it yourself as:
|
|
22
57
|
|
23
58
|
## Usage
|
24
59
|
|
25
|
-
|
60
|
+
```ruby
|
61
|
+
5.times { puts placeholder_url } # =>
|
62
|
+
# //placebear.com//100/100
|
63
|
+
# //stevensegallery.com//100/100
|
64
|
+
# //placecage.com/g/100/100
|
65
|
+
# //stevensegallery.com/g/100/100
|
66
|
+
# //lorempixel.com//100/100
|
67
|
+
|
68
|
+
# If you specify just a width, the height will be the same as the width
|
69
|
+
placeholder_url(150)
|
70
|
+
# => "//fillmurray.com//150/150"
|
71
|
+
|
72
|
+
# You can specify width and height separately.
|
73
|
+
placeholder_url(150, 250)
|
74
|
+
# => "//fillmurray.com//150/250"
|
75
|
+
|
76
|
+
# You acn specify the site to use from the list below. It will raise an error
|
77
|
+
# if you send an invalid site.
|
78
|
+
placeholder_url(150, 150, site: 'placecage')
|
79
|
+
# => "//placecage.com//150/150"
|
80
|
+
placeholder_url(150, 150, site: 'lorempixel')
|
81
|
+
# => "//lorempixel.com/g/150/150"
|
82
|
+
placeholder_url(150, 150, site: 'asd')
|
83
|
+
# => ArgumentError: Site not supported
|
84
|
+
|
85
|
+
# The style option will pick an appropriate placeholder site for the style
|
86
|
+
# you want. It'll raise an ArgumentError if you send a style that doesn't have
|
87
|
+
# a corresponding site.
|
88
|
+
placeholder_url(150, 150, style: 'g')
|
89
|
+
# => "//fillmurray.com/g/150/150"
|
90
|
+
placeholder_url(150, 150, style: 'c')
|
91
|
+
# => "//placecage.com/c/150/150"
|
92
|
+
placeholder_url(150, 150, style: 'p')
|
93
|
+
# => ArgumentError: No Supported Placeholder Site With This Style - Try g, c, or gif
|
94
|
+
|
95
|
+
# You can specify both style and site. Although if the combo doesn't exist, it'll
|
96
|
+
# raise an error
|
97
|
+
placeholder_url(150, 150, style: 'g', site: 'placecage')
|
98
|
+
# => "//placecage.com/g/150/150"
|
99
|
+
placeholder_url(150, 150, style: 'c', site: 'fillmurray')
|
100
|
+
# => ArgumentError: Style not supported by this site
|
101
|
+
|
102
|
+
# placeholder_tag generates an image_tag with the url generated from passing the
|
103
|
+
# given parameters through to placeholder_url
|
104
|
+
5.times { puts placeholder_tag } # =>
|
105
|
+
# <img alt="placeholder-100x100" src="//stevensegallery.com//100/100" />
|
106
|
+
# <img alt="placeholder-100x100" src="//lorempixel.com//100/100" />
|
107
|
+
# <img alt="placeholder-100x100" src="//stevensegallery.com//100/100" />
|
108
|
+
# <img alt="placeholder-100x100" src="//fillmurray.com/g/100/100" />
|
109
|
+
# <img alt="placeholder-100x100" src="//placebear.com//100/100" />
|
110
|
+
```
|
26
111
|
|
27
112
|
## Development
|
28
113
|
|
29
|
-
|
114
|
+
1. bundle install
|
115
|
+
2. rake spec
|
116
|
+
3. 'rails c' to enter a rails console with the placepic gem loaded
|
30
117
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
118
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
32
119
|
|
33
120
|
## Contributing
|
34
121
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
122
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Lockyy/placepic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
123
|
|
37
124
|
|
38
125
|
## License
|
data/Rakefile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
5
|
|
4
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
require File.expand_path('../config/application', __FILE__)
|
5
8
|
|
6
9
|
task :default => :spec
|
10
|
+
Rails.application.load_tasks
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>App</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<style>
|
12
|
+
.example {
|
13
|
+
min-width: 33%;
|
14
|
+
display: inline-table;
|
15
|
+
text-align: center;
|
16
|
+
}
|
17
|
+
</style>
|
18
|
+
|
19
|
+
<%= yield %>
|
20
|
+
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
.example
|
2
|
+
.function placeholder_tag
|
3
|
+
.image
|
4
|
+
= placeholder_tag
|
5
|
+
|
6
|
+
.example
|
7
|
+
.function placeholder_tag(200)
|
8
|
+
.image
|
9
|
+
= placeholder_tag(200)
|
10
|
+
|
11
|
+
.example
|
12
|
+
.function placeholder_tag(100, 200)
|
13
|
+
.image
|
14
|
+
= placeholder_tag(100, 200)
|
15
|
+
|
16
|
+
.example
|
17
|
+
.function placeholder_tag(700, 100)
|
18
|
+
.image
|
19
|
+
= placeholder_tag(700, 100)
|
20
|
+
|
21
|
+
- height = rand(100..200)
|
22
|
+
- width = rand(100..200)
|
23
|
+
.example
|
24
|
+
.function placeholder_tag(#{height}, #{width}, site: 'placecage')
|
25
|
+
.image
|
26
|
+
= placeholder_tag(height, width, site: 'placecage')
|
27
|
+
|
28
|
+
- height = rand(100..200)
|
29
|
+
- width = rand(100..200)
|
30
|
+
.example
|
31
|
+
.function placeholder_tag(#{height}, #{width}, site: 'lorempixel')
|
32
|
+
.image
|
33
|
+
= placeholder_tag(height, width, site: 'lorempixel')
|
34
|
+
|
35
|
+
- height = rand(100..200)
|
36
|
+
- width = rand(100..200)
|
37
|
+
.example
|
38
|
+
.function placeholder_tag(#{height}, #{width}, site: 'placebear')
|
39
|
+
.image
|
40
|
+
= placeholder_tag(height, width, site: 'placebear')
|
41
|
+
|
42
|
+
- height = rand(100..200)
|
43
|
+
- width = rand(100..200)
|
44
|
+
.example
|
45
|
+
.function placeholder_tag(#{height}, #{width}, style: 'gif')
|
46
|
+
.image
|
47
|
+
= placeholder_tag(height, width, style: 'gif')
|
48
|
+
|
49
|
+
- height = rand(100..200)
|
50
|
+
- width = rand(100..200)
|
51
|
+
.example
|
52
|
+
.function placeholder_tag(#{height}, #{width}, style: 'g')
|
53
|
+
.image
|
54
|
+
= placeholder_tag(height, width, style: 'g')
|
55
|
+
|
56
|
+
- height = rand(100..200)
|
57
|
+
- width = rand(100..200)
|
58
|
+
.example
|
59
|
+
.function placeholder_tag(#{height}, #{width}, style: 'c')
|
60
|
+
.image
|
61
|
+
= placeholder_tag(height, width, style: 'c')
|
62
|
+
|
63
|
+
- height = rand(100..200)
|
64
|
+
- width = rand(100..200)
|
65
|
+
.example
|
66
|
+
.function placeholder_tag(#{height}, #{width}, site: 'placebear', style: 'g')
|
67
|
+
.image
|
68
|
+
= placeholder_tag(height, width, site: 'placebear', style: 'g')
|
data/bin/bundle
ADDED
data/bin/rails
ADDED
data/bin/rake
ADDED
data/bin/setup
CHANGED
@@ -1,7 +1,29 @@
|
|
1
|
-
#!/bin/
|
2
|
-
|
3
|
-
IFS=$'\n\t'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
4
3
|
|
5
|
-
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
6
|
|
7
|
-
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
data/bin/spring
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This file loads spring without using Bundler, in order to be fast.
|
4
|
+
# It gets overwritten when you run the `spring binstub` command.
|
5
|
+
|
6
|
+
unless defined?(Spring)
|
7
|
+
require "rubygems"
|
8
|
+
require "bundler"
|
9
|
+
|
10
|
+
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
|
11
|
+
Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
|
12
|
+
gem "spring", match[1]
|
13
|
+
require "spring/binstub"
|
14
|
+
end
|
15
|
+
end
|
data/config.ru
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "action_mailer/railtie"
|
5
|
+
require "sprockets/railtie"
|
6
|
+
require "rails/test_unit/railtie"
|
7
|
+
|
8
|
+
# Require the gems listed in Gemfile, including any gems
|
9
|
+
# you've limited to :test, :development, or :production.
|
10
|
+
Bundler.require(*Rails.groups)
|
11
|
+
|
12
|
+
module App
|
13
|
+
class Application < Rails::Application
|
14
|
+
end
|
15
|
+
end
|
data/config/boot.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
23
|
+
# This option may cause significant delays in view rendering with a large
|
24
|
+
# number of complex assets.
|
25
|
+
config.assets.debug = true
|
26
|
+
|
27
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
28
|
+
# yet still be able to expire them through the digest params.
|
29
|
+
config.assets.digest = true
|
30
|
+
|
31
|
+
# Adds additional error checking when serving assets at runtime.
|
32
|
+
# Checks for improperly declared sprockets dependencies.
|
33
|
+
# Raises helpful error messages.
|
34
|
+
config.assets.raise_runtime_errors = true
|
35
|
+
|
36
|
+
# Raises error for missing translations
|
37
|
+
# config.action_view.raise_on_missing_translations = true
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
31
|
+
# ActionMailer::Base.deliveries array.
|
32
|
+
config.action_mailer.delivery_method = :test
|
33
|
+
|
34
|
+
# Randomize the order test cases are executed.
|
35
|
+
config.active_support.test_order = :random
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr.
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Raises error for missing translations
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
42
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
data/config/routes.rb
ADDED
data/config/secrets.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: f1c1731c3a2147f6e98f2aa47ded9b7cf2ef5fac5abd9ea34af4f5b519ce661dae1ef3e27fdd07d55168444a62f2f3b5a3b3f52eed6c8d1fee47aff6757da39a
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 371e9cfa25177ae886de56a8e86678b08b58ba4e62a2e6602179e1b1bf52b4eaf7cd47a9ede81b25754827e4fb8c1a5e019842a671f723bb6e78ea5d6ced39e5
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -1,17 +1,30 @@
|
|
1
1
|
module PlacePic
|
2
2
|
module Placeholders
|
3
3
|
|
4
|
-
def placeholder_tag(width, height, opts = {})
|
5
|
-
|
6
|
-
|
4
|
+
def placeholder_tag(width = 100, height = nil, opts = {})
|
5
|
+
Placeholders.placeholder_tag(width, height, opts)
|
6
|
+
end
|
7
7
|
|
8
|
-
|
8
|
+
def placeholder_url(width = 100, height = nil, opts = {})
|
9
|
+
Placeholders.placeholder_url(width, height, opts)
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
class << self
|
13
|
+
def placeholder_tag(width = 100, height = nil, opts = {})
|
14
|
+
height = width unless height
|
15
|
+
image_url = placeholder_url(width, height, opts)
|
16
|
+
tag_opts = opts.except(:style, :site)
|
17
|
+
tag_opts[:alt] = "placeholder-#{width}x#{height}" unless tag_opts[:alt]
|
18
|
+
|
19
|
+
ActionController::Base.helpers.image_tag(image_url, tag_opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def placeholder_url(width = 100, height = nil, opts = {})
|
23
|
+
height = width unless height
|
24
|
+
url, style = PlacePic::Urls.url_and_style(opts)
|
13
25
|
|
14
|
-
|
26
|
+
"//#{url}.com/#{style}/#{width}/#{height}"
|
27
|
+
end
|
15
28
|
end
|
16
29
|
end
|
17
30
|
end
|
data/lib/placepic/urls.rb
CHANGED
@@ -2,9 +2,6 @@ module PlacePic
|
|
2
2
|
class Urls
|
3
3
|
class << self
|
4
4
|
URLS = {
|
5
|
-
'baconmockup' => {
|
6
|
-
styles: ['']
|
7
|
-
},
|
8
5
|
'placebear' => {
|
9
6
|
styles: ['', 'g']
|
10
7
|
},
|
@@ -30,11 +27,11 @@ module PlacePic
|
|
30
27
|
# If the user asked for a specific URL then try and get them it.
|
31
28
|
# If it doesn't exist, throw an error.
|
32
29
|
if requested_url
|
33
|
-
|
30
|
+
raise ArgumentError, 'Site not supported' unless URLS.keys.include? requested_url
|
34
31
|
# If they also requested a style, try to get them it.
|
35
32
|
# Throw an error if that url doesn't support that style
|
36
33
|
if requested_style
|
37
|
-
|
34
|
+
raise ArgumentError, 'Style not supported by this site' unless URLS[requested_url][:styles].include? requested_style
|
38
35
|
return [requested_url, requested_style]
|
39
36
|
end
|
40
37
|
return [requested_url, random_style_for_url(requested_url)]
|
@@ -54,10 +51,8 @@ module PlacePic
|
|
54
51
|
url = urls.sample(1)[0]
|
55
52
|
|
56
53
|
return url if url
|
57
|
-
|
58
|
-
%q(
|
59
|
-
No Supported Placeholder Sites With This Style -
|
60
|
-
Try g, c, or gif)
|
54
|
+
raise ArgumentError,
|
55
|
+
%q(No Supported Placeholder Site With This Style - Try g, c, or gif)
|
61
56
|
end
|
62
57
|
|
63
58
|
# Get a random service, and a random style for that service
|
data/lib/placepic/version.rb
CHANGED
data/placepic.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Daniel Lockhart"]
|
10
10
|
spec.email = ["daniel@lockyy.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Generate a random placeholder image from various placeholder sites
|
12
|
+
spec.summary = %q{Generate a random placeholder image from various placeholder sites}
|
13
13
|
spec.description = %q{Generate a random placeholder image url or tag from
|
14
|
-
|
14
|
+
placebear, stevensegallery, fillmurray,
|
15
15
|
placecage, or lorempixel.}
|
16
16
|
spec.homepage = "https://github.com/Lockyy/PlacePic."
|
17
17
|
spec.license = "MIT"
|
data/public/404.html
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
data/public/422.html
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
data/public/500.html
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: placepic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lockhart
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
description: |-
|
56
56
|
Generate a random placeholder image url or tag from
|
57
|
-
|
57
|
+
placebear, stevensegallery, fillmurray,
|
58
58
|
placecage, or lorempixel.
|
59
59
|
email:
|
60
60
|
- daniel@lockyy.com
|
@@ -70,13 +70,42 @@ files:
|
|
70
70
|
- LICENSE.txt
|
71
71
|
- README.md
|
72
72
|
- Rakefile
|
73
|
+
- app/controllers/application_controller.rb
|
74
|
+
- app/controllers/concerns/.keep
|
75
|
+
- app/controllers/test_controller.rb
|
76
|
+
- app/views/layouts/application.html.erb
|
77
|
+
- app/views/test/show.html.slim
|
78
|
+
- bin/bundle
|
73
79
|
- bin/console
|
80
|
+
- bin/rails
|
81
|
+
- bin/rake
|
74
82
|
- bin/setup
|
83
|
+
- bin/spring
|
84
|
+
- config.ru
|
85
|
+
- config/application.rb
|
86
|
+
- config/boot.rb
|
87
|
+
- config/environment.rb
|
88
|
+
- config/environments/development.rb
|
89
|
+
- config/environments/test.rb
|
90
|
+
- config/initializers/assets.rb
|
91
|
+
- config/initializers/backtrace_silencers.rb
|
92
|
+
- config/initializers/cookies_serializer.rb
|
93
|
+
- config/initializers/filter_parameter_logging.rb
|
94
|
+
- config/initializers/inflections.rb
|
95
|
+
- config/initializers/mime_types.rb
|
96
|
+
- config/initializers/session_store.rb
|
97
|
+
- config/initializers/wrap_parameters.rb
|
98
|
+
- config/locales/en.yml
|
99
|
+
- config/routes.rb
|
100
|
+
- config/secrets.yml
|
75
101
|
- lib/placepic.rb
|
76
102
|
- lib/placepic/placeholders.rb
|
77
103
|
- lib/placepic/urls.rb
|
78
104
|
- lib/placepic/version.rb
|
79
105
|
- placepic.gemspec
|
106
|
+
- public/404.html
|
107
|
+
- public/422.html
|
108
|
+
- public/500.html
|
80
109
|
homepage: https://github.com/Lockyy/PlacePic.
|
81
110
|
licenses:
|
82
111
|
- MIT
|
@@ -100,5 +129,5 @@ rubyforge_project:
|
|
100
129
|
rubygems_version: 2.4.8
|
101
130
|
signing_key:
|
102
131
|
specification_version: 4
|
103
|
-
summary: Generate a random placeholder image from various placeholder sites
|
132
|
+
summary: Generate a random placeholder image from various placeholder sites
|
104
133
|
test_files: []
|