Class: Blog
Overview
The Blog class represents the one and only blog. It stores most configuration settings and is linked to most of the assorted content classes via has_many.
Once upon a time, there were plans to make publify handle multiple blogs, but it never happened and publify is now firmly single-blog.
Defined Under Namespace
Modules: BasedUrlFor
Constant Summary
StringLengthLimit::STRING_LIMIT
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#canonicalize, included
#url_for
Instance Attribute Details
#custom_permalink ⇒ Object
Returns the value of attribute custom_permalink.
29
30
31
|
# File 'app/models/blog.rb', line 29
def custom_permalink
@custom_permalink
end
|
Class Method Details
.find_blog(base_url) ⇒ Object
Find the Blog that matches a specific base URL. If no Blog object is found that matches, then grab the first blog. If that fails, then create a new Blog. The last case should only be used when Publify is first installed.
149
150
151
|
# File 'app/models/blog.rb', line 149
def self.find_blog(base_url)
Blog.find_by(base_url: base_url) || Blog.first || Blog.new
end
|
Instance Method Details
#allow_signup? ⇒ Boolean
256
257
258
|
# File 'app/models/blog.rb', line 256
def allow_signup?
allow_signup == 1
end
|
#articles_matching(query, args = {}) ⇒ Object
212
213
214
|
# File 'app/models/blog.rb', line 212
def articles_matching(query, args = {})
Article.search(query, args)
end
|
Check that all required blog settings have a value.
158
159
160
|
# File 'app/models/blog.rb', line 158
def configured?
settings.key?("blog_name")
end
|
#current_theme(reload = nil) ⇒ Object
The Theme
object for the current theme.
163
164
165
166
|
# File 'app/models/blog.rb', line 163
def current_theme(reload = nil)
@current_theme = nil if reload
@current_theme ||= Theme.find(theme) || Theme.new("", "")
end
|
#file_url(filename) ⇒ Object
The URL for a static file.
204
205
206
207
208
209
210
|
# File 'app/models/blog.rb', line 204
def file_url(filename)
if CarrierWave.configure { |config| config.storage.name == "CarrierWave::Storage::Fog" }
filename
else
url_for filename, only_path: false
end
end
|
#global_pings_enabled? ⇒ Boolean
153
154
155
|
# File 'app/models/blog.rb', line 153
def global_pings_enabled?
!global_pings_disable?
end
|
249
250
251
252
253
254
|
# File 'app/models/blog.rb', line 249
def
return false if .nil? || .nil?
return false if .empty? || .empty?
true
end
|
#per_page(format) ⇒ Object
216
217
218
219
220
|
# File 'app/models/blog.rb', line 216
def per_page(format)
return limit_article_display if format.nil? || format == "html"
end
|
#permalink_has_identifier ⇒ Object
231
232
233
234
235
236
237
238
239
|
# File 'app/models/blog.rb', line 231
def permalink_has_identifier
unless /(%title%)/.match?(permalink_format)
errors.add(:base, I18n.t("errors.permalink_need_a_title"))
end
if /\.(atom|rss)$/.match?(permalink_format)
errors.add(:permalink_format, I18n.t("errors.cant_end_with_rss_or_atom"))
end
end
|
#root_path ⇒ Object
241
242
243
|
# File 'app/models/blog.rb', line 241
def root_path
split_base_url[:root_path]
end
|
222
223
224
225
226
227
228
229
|
# File 'app/models/blog.rb', line 222
def
limit = .to_i
if limit.zero?
{}
else
{ limit: limit }
end
end
|
#shortener_url ⇒ Object
260
261
262
|
# File 'app/models/blog.rb', line 260
def shortener_url
custom_url_shortener.present? ? custom_url_shortener : base_url
end
|
#text_filter_object ⇒ Object