私の方はというとAWSの1年間無料利用枠が4月で期限切れになりまして、先月よりきっちり従量課金されるようになりました。その額なんと
56.04 [USD] -> 5,720[JPY]
GW中に調子に乗ってWordpressのDBをlocalhostからRDSに変えなきゃよかった・・・。という反省はさておき、
しました。その際困ったのがブログの更新をどうホームページ上で見せるか?というもの。
こんなの

まぁそういうのはフィードを使うと相場は決まっているわけでして、例に漏れずやってみました。
こんなの
まぁそういうのはフィードを使うと相場は決まっているわけでして、例に漏れずやってみました。
feedzirraを使った更新一覧表示
rubygemでRSSのパーサーを探していたらfeedzirraに出会いました。他にもいろいろ出会いましたがThe Ruby Toolbox - Atom & RSS Feed Parsingによると一番人気があるようだったので利用。コードは以下です。
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
#!/usr/bin/ruby | |
# -*- coding:utf-8 -*- | |
require 'sinatra' | |
require 'feedzirra' | |
atom_url = 'http://blog.takkyuuplayer.com/feeds/posts/summary' | |
get '/' do | |
feed = Feedzirra::Feed.fetch_and_parse(atom_url) | |
erb :index, :locals => { :feed => feed } | |
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
<% feed.entries.each do |entry| %> | |
<li> | |
<a href="<%= entry.url %>" target="_blank"> | |
<%= entry.published.to_s[0, 10].gsub('-', '/') %> | |
<%= entry.title %> | |
</a> | |
</li> | |
<% 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
proxy_cache_path /var/cache/nginx/sinatra levels=1:2 keys_zone=cache_static_file:128m inactive=7d max_size=512m; | |
proxy_temp_path /var/cache/nginx/temp; | |
upstream sinatra { | |
server localhost:4567; | |
} | |
server { | |
listen 80; | |
server_name www.takkyuuplayer.com; | |
charset utf-8; | |
access_log /var/log/nginx/vh/sinatra-access.log; | |
error_log /var/log/nginx/vh/sinatra-error.log; | |
location / { | |
proxy_redirect off; | |
set $do_not_cache 0; | |
if ($request_method != GET) { | |
set $do_not_cache 1; | |
} | |
proxy_no_cache $do_not_cache; | |
proxy_cache_bypass $do_not_cache; | |
proxy_cache cache_static_file; | |
proxy_cache_key $scheme$host$uri$is_args$args; | |
proxy_cache_valid 200 2h; | |
proxy_cache_valid any 1m; | |
proxy_pass http://sinatra; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $http_host; | |
} |
0 件のコメント:
コメントを投稿