Class: Postview::Site
- Inherits:
-
Object
- Object
- Postview::Site
- Defined in:
- lib/postview/site.rb
Overview
Copyright © 2009 Hallison Batista
Instance Attribute Summary collapse
-
#author ⇒ Object
Author site.
-
#directory ⇒ Object
Remote directory for site.
-
#domain ⇒ Object
Domain for host site.
-
#email ⇒ Object
Email to contact author.
-
#find ⇒ Object
Finder for posts.
-
#find_in_archive ⇒ Object
Finder for archived posts.
-
#find_in_drafts ⇒ Object
Finder for drafted posts.
-
#subtitle ⇒ Object
Subtitle.
-
#theme ⇒ Object
Theme directory name.
-
#title ⇒ Object
Site title.
-
#token ⇒ Object
Token pass.
Class Method Summary collapse
-
.tokenize(username, password, domain) ⇒ Object
Generate digest token.
Instance Method Summary collapse
-
#authenticate?(username, password) ⇒ Boolean
Check authentication for user.
-
#find_all_posts_tagged_with(tag) ⇒ Object
Find all posts tagged with a specific tag.
-
#find_all_tags ⇒ Object
Find all tags from all posts and archived posts.
-
#find_tag(tag) ⇒ Object
Find a specific tag from posts and archived posts.
-
#initialize(attributes = {}) ⇒ Site
constructor
Initialize site with attributes passed by arguments.
-
#search_posts(*values) ⇒ Object
Find posts using any string values.
Constructor Details
#initialize(attributes = {}) ⇒ Site
Initialize site with attributes passed by arguments.
40 41 42 |
# File 'lib/postview/site.rb', line 40 def initialize(attributes = {}) attributes.instance_variables_set_to(self) end |
Instance Attribute Details
#author ⇒ Object
Author site
13 14 15 |
# File 'lib/postview/site.rb', line 13 def @author end |
#directory ⇒ Object
Remote directory for site
22 23 24 |
# File 'lib/postview/site.rb', line 22 def directory @directory end |
#domain ⇒ Object
Domain for host site
19 20 21 |
# File 'lib/postview/site.rb', line 19 def domain @domain end |
#email ⇒ Object
Email to contact author
16 17 18 |
# File 'lib/postview/site.rb', line 16 def email @email end |
#find ⇒ Object
Finder for posts
31 32 33 |
# File 'lib/postview/site.rb', line 31 def find @find end |
#find_in_archive ⇒ Object
Finder for archived posts
34 35 36 |
# File 'lib/postview/site.rb', line 34 def find_in_archive @find_in_archive end |
#find_in_drafts ⇒ Object
Finder for drafted posts
37 38 39 |
# File 'lib/postview/site.rb', line 37 def find_in_drafts @find_in_drafts end |
#subtitle ⇒ Object
Subtitle
10 11 12 |
# File 'lib/postview/site.rb', line 10 def subtitle @subtitle end |
#theme ⇒ Object
Theme directory name.
25 26 27 |
# File 'lib/postview/site.rb', line 25 def theme @theme end |
#title ⇒ Object
Site title.
7 8 9 |
# File 'lib/postview/site.rb', line 7 def title @title end |
#token ⇒ Object
Token pass.
28 29 30 |
# File 'lib/postview/site.rb', line 28 def token @token end |
Class Method Details
.tokenize(username, password, domain) ⇒ Object
Generate digest token.
71 72 73 74 |
# File 'lib/postview/site.rb', line 71 def self.tokenize(username, password, domain) require 'digest' Digest::SHA256.hexdigest("$#{username}?#{password}@#{domain}") end |
Instance Method Details
#authenticate?(username, password) ⇒ Boolean
Check authentication for user.
66 67 68 |
# File 'lib/postview/site.rb', line 66 def authenticate?(username, password) @token == self.class.tokenize(username, password, domain) end |
#find_all_posts_tagged_with(tag) ⇒ Object
Find all posts tagged with a specific tag.
55 56 57 |
# File 'lib/postview/site.rb', line 55 def find_all_posts_tagged_with(tag) [ find.all_posts_by_tag(tag), find_in_archive.all_posts_by_tag(tag) ] end |
#find_all_tags ⇒ Object
Find all tags from all posts and archived posts.
45 46 47 |
# File 'lib/postview/site.rb', line 45 def (find. + find_in_archive.).uniq.sort end |
#find_tag(tag) ⇒ Object
Find a specific tag from posts and archived posts.
50 51 52 |
# File 'lib/postview/site.rb', line 50 def find_tag(tag) find.tag(tag) || find_in_archive.tag(tag) end |
#search_posts(*values) ⇒ Object
Find posts using any string values. Returns two lists: posts and archived posts.
61 62 63 |
# File 'lib/postview/site.rb', line 61 def search_posts(*values) [ find.posts(*values), find_in_archive.posts(*values) ] end |