Merge branch 'master' of https://github.com/r888888888/danbooru
This commit is contained in:
@@ -32,53 +32,44 @@ class Cache
|
||||
end
|
||||
|
||||
def self.get(key, expiry = 0)
|
||||
begin
|
||||
start_time = Time.now
|
||||
value = MEMCACHE.get key.slice(0, 200)
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Get (%0.6f) %s -> %s' % [elapsed, key, value])
|
||||
if value.nil? and block_given? then
|
||||
value = yield
|
||||
MEMCACHE.set key, value, expiry
|
||||
end
|
||||
value
|
||||
rescue MemCache::MemCacheError => err
|
||||
ActiveRecord::Base.logger.debug "MemCache Error: #{err.message}"
|
||||
if block_given? then
|
||||
value = yield
|
||||
put key, value, expiry
|
||||
end
|
||||
value
|
||||
start_time = Time.now
|
||||
value = MEMCACHE.get key
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Get (%0.6f) %s -> %s' % [elapsed, key, value])
|
||||
if value.nil? and block_given? then
|
||||
value = yield
|
||||
MEMCACHE.set key, value, expiry
|
||||
end
|
||||
value
|
||||
rescue => err
|
||||
ActiveRecord::Base.logger.debug "MemCache Error: #{err.message}"
|
||||
if block_given? then
|
||||
value = yield
|
||||
put key, value, expiry
|
||||
end
|
||||
value
|
||||
end
|
||||
|
||||
def self.put(key, value, expiry = 0)
|
||||
key.gsub!(/\s/, "_")
|
||||
key = key[0, 200]
|
||||
|
||||
begin
|
||||
start_time = Time.now
|
||||
MEMCACHE.set key, value, expiry
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Set (%0.6f) %s -> %s' % [elapsed, key, value])
|
||||
value
|
||||
rescue MemCache::MemCacheError => err
|
||||
ActiveRecord::Base.logger.debug "MemCache Error: #{err.message}"
|
||||
nil
|
||||
end
|
||||
start_time = Time.now
|
||||
MEMCACHE.set key, value, expiry
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Set (%0.6f) %s -> %s' % [elapsed, key, value])
|
||||
value
|
||||
rescue => err
|
||||
ActiveRecord::Base.logger.debug "MemCache Error: #{err.message}"
|
||||
nil
|
||||
end
|
||||
|
||||
def self.delete(key, delay = nil)
|
||||
begin
|
||||
start_time = Time.now
|
||||
MEMCACHE.delete key, delay
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Delete (%0.6f) %s' % [elapsed, key])
|
||||
nil
|
||||
rescue MemCache::MemCacheError => err
|
||||
ActiveRecord::Base.logger.debug "MemCache Error: #{err.message}"
|
||||
nil
|
||||
end
|
||||
start_time = Time.now
|
||||
MEMCACHE.delete key, delay
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Delete (%0.6f) %s' % [elapsed, key])
|
||||
nil
|
||||
rescue => err
|
||||
ActiveRecord::Base.logger.debug "MemCache Error: #{err.message}"
|
||||
nil
|
||||
end
|
||||
|
||||
def self.sanitize(key)
|
||||
|
||||
@@ -235,7 +235,7 @@ class PostPresenter < Presenter
|
||||
|
||||
if pool.neighbors(@post).next
|
||||
@next_post_in_pool = pool.neighbors(@post).next
|
||||
pool_html << template.link_to("next ›".html_safe, template.post_path(pool.neighbors(@post).next, :pool_id => pool.id), :rel => next_rel, :class => "#{klass} next", :title => "to page #{pool.page_number(pool.neighbors(@post).next)}")
|
||||
pool_html << template.link_to("next ›".html_safe, template.post_path(@next_post_in_pool, :pool_id => pool.id), :rel => next_rel, :class => "#{klass} next", :title => "to page #{pool.page_number(@next_post_in_pool)}")
|
||||
match_found = true
|
||||
else
|
||||
pool_html << '<span class="next">next ›</span>'
|
||||
|
||||
@@ -108,14 +108,14 @@
|
||||
<meta name="post-is-flagged" content="<%= @post.is_flagged? %>">
|
||||
<meta name="config-large-width" content="<%= Danbooru.config.large_image_width %>">
|
||||
<meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
|
||||
<meta property="og:title" content="<%= h @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
|
||||
<meta property="og:description" content="<%= h @post.presenter.humanized_tag_string %>">
|
||||
<meta property="og:title" content="<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
|
||||
<meta property="og:description" content="<%= @post.presenter.humanized_tag_string %>">
|
||||
<meta property="og:image" content="<%= @post.preview_file_url %>">
|
||||
|
||||
<!-- Twitter properties -->
|
||||
<% if @post.twitter_card_supported? %>
|
||||
<meta name="twitter:card" content="photo">
|
||||
<meta name="twitter:image:src" content="http://<%= Danbooru.config.hostname %><%= @post.file_url %>">
|
||||
<meta name="twitter:image:src" content="http://<%= Danbooru.config.hostname %><%= @post.large_file_url %>">
|
||||
<meta name="twitter:image:width" content="<%= @post.image_width %>">
|
||||
<meta name="twitter:image:height" content="<%= @post.image_height %>">
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user