-
-
Save IskanderHaziev/838714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Post.fetch # fetch post from remote resources and save to the Post | |
Post::Tumblr.fetch # fetch post from Tumblr and save to the Post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# skinnycms/app/models/post.rb | |
class Post < ActiveRecord::Base | |
cattr_accessor :plugins | |
def fetch | |
plugins.each do |plugin| | |
Post.constantize(plugin).fetch | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# skinnycms/app/models/post/base.rb | |
class Post::Base | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# skinnycms_wordpress/init.rb | |
require 'app/models/post/wordpress' | |
Post.plugins << 'wordpress' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# skinnycms_wordpress/app/models/post/wordpress.rb | |
class Post::Wordpress < Post::Base | |
def self.fetch | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# skinnycms/app/controllers/posts_controller.rb | |
class PostsController << ApplicationController | |
def index | |
@posts = Post.all | |
end | |
def videos | |
@posts = Post.where(:post_type => 'video').all | |
end | |
def posts_from_tumblr | |
@posts = Post.where(:source => 'tumblr').all | |
end | |
def images_from_tumblr | |
@posts = Post.where(:source => 'tumblr', :post_type => 'image').all | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment