Skip to content

Commit

Permalink
Merge pull request #834 from tdiary/use_amazon_heroku
Browse files Browse the repository at this point in the history
use amazon plugin on heroku again
  • Loading branch information
tdtds committed Dec 1, 2019
2 parents cb46626 + b234315 commit f6b66be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 deletions.
46 changes: 11 additions & 35 deletions doc/INSTALL-paas.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,36 @@
Install to PaaS
=====================
# Install to PaaS

概要
--
## 概要

tDiary-3.1.3 以降のバージョンでは tDiary を [Heroku](http://www.heroku.com) のような PasS で動かすことが可能です。PaaS を利用することで、3.1.3 以前のバージョンで必要とされていた Apache のような http サーバーの用意や CGI として動作させるための環境設定を行う事なく、 tDiary を動かして日記を書くことが可能となります。

動かし方 - Heroku の場合
----
## 動かし方 - Heroku の場合

Webブラウザだけあれば動作させることが可能です。

日記の更新時にTwitterのOAuthを使って認証するようになっています。あらかじめ[Twitter Application Management](https://apps.twitter.com/)にてアプリケーションを作成し、Consumer Key (API Key)Consumer Secret (API Secret) を取得しておきます。
日記の更新時にTwitterのOAuthを使って認証するようになっています。あらかじめ[Twitter Developpers](https://developer.twitter.com/en/apps)にてアプリケーションを作成し、API key と API secret key を取得しておきます。

続いて GitHub 上にある[tDiaryのリポジトリ](https://github.com/tdiary/tdiary-core)から、Herokuボタンを使ってデプロイしてください(トップページ下部のREADMEにあります)。

Heroku の New App ページになったら、下記の情報を入力して、Deploy for Free ボタンを押します。

* App Name (任意)
* TWITTER_KEY: Twitter の Consumer Key (API Key)
* TWITTER_SECRET: Twitter の Consumer Secret (API Secret)
* TWITTER_KEY: Twitter の API key
* TWITTER_SECRET: Twitter の API secret key
* TWITTER_NAME: 認証に使う Twitter のユーザ名

「Deployed to Heroku」まで進めば利用可能です。「View it」のリンクから日記に飛んで下さい。

【注意】View itから飛んだ先のURLは https://~ になっています。いったん http://~ にしないと認証が通らないので注意してください。なお、設定画面で「日記のURL」を https://~ に変更することで https での利用が可能です。

独自のテーマファイルを使う方法
----
また、tDiary 5.10 より、amazonプラグインを利用する場合に特別な設定が必要になっています。[tDiary 5.1.0のリリース](http://www.tdiary.org/20191129.html)にある方法でAmazon PA-APIのアクセスキーとシークレットキーを取得し、Herokuの環境変数(Settings→Config Vars)にてぞれぞれ以下の変数に指定します。

Heroku で自作や tdiary-theme に含まれるテーマファイルを用いるには、deploy 対象としてテーマファイルを登録し、Heroku に転送する必要があります。
* AMAZON_ACCESS_KEY
* AMAZON_SECRET_KEY

tdiary-core の deploy ブランチに切り替えます。

```
git checkout deploy
```

テーマファイルをコピーし、deploy 対象として登録します。

```
cp -rf ~/tdiary-theme/gustav theme
git add .
git commit -m "add theme file"
```

Heroku にファイルを転送します。

```
git push heroku deploy:master
```

これで tDiary on Heroku の設定画面よりコピーしたテーマファイルを選択できるようになります。
あとはtDiaryの設定画面から、AmazonのアソシエイトIDを指定すれば利用できます。

memcache アドオンを使う方法 - Heroku の場合
----
## memcache アドオンを使う方法 - Heroku の場合

Heroku で アドオンの追加・削除を行うことが出来るユーザーは memcache アドオンを使うことで、より高速に日記キャッシュデータを扱えるようになります。tDiary on Heroku で memcache アドオンを使う方法を以下に解説します。

Expand Down
3 changes: 3 additions & 0 deletions misc/paas/heroku/tdiary.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ require 'tempfile'
@options['comment_mail.authentication'] = :plain
@options['comment_mail.starttls'] = true

@options['amazon.access_key'] = ENV['AMAZON_ACCESS_KEY']
@options['amazon.secret_key'] = ENV['AMAZON_SECRET_KEY']

@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
@options['spamfilter.bad_ip_addrs'] = ""
@options['spamfilter.bad_mail_patts'] = "(mu@alloha\\.info|mumu2004@mail\\.com|zhongleibo|dfd@12\\.com|anonimous|aol\\.|yahoo\\.|google\\.|hotmail\\.|msn\\.|leroy\\.|ablare\\.|gmx\\.|lorazepam|\\.co$)"
Expand Down

0 comments on commit f6b66be

Please sign in to comment.