Markdown でかけるようにする#
[参考サイト](https://pypi.org/project/mezzanine-pagedown/ https://www.monotalk.xyz/blog/mezzanine%E3%81%AEpagedown%E3%81%ABcodehilite%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B/)
- インストールと settings.py への追加
(py36) [tenn25@ip-10-0-0-51 tenn25blog]$ pip install mezzanine-pagedown
(py36) [tenn25@ip-10-0-0-51 mezzanine_pagedown]$ pip install Pygments
(py36) [tenn25@ip-10-0-0-51 mezzanine_pagedown]$ sudo vi /opt/blog/tenn25blog/tenn25blog/settings.py
以下を設定
################
# APPLICATIONS #
################
INSTALLED_APPS = (
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.redirects",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.sitemaps",
"django.contrib.staticfiles",
"mezzanine.boot",
"mezzanine.conf",
"mezzanine.core",
"mezzanine.generic",
"mezzanine.pages",
"mezzanine.blog",
"mezzanine.forms",
"mezzanine.galleries",
"mezzanine.twitter",
# "mezzanine.accounts",
"mezzanine_pagedown"
)
####################
# mezzanne-pagedown #
####################
RICHTEXT_WIDGET_CLASS = 'mezzanine_pagedown.widgets.PageDownWidget'
RICHTEXT_FILTER = 'mezzanine_pagedown.filters.custom'
RICHTEXT_FILTERS = (RICHTEXT_FILTER,)
PAGEDOWN_MARKDOWN_EXTENSIONS = ('extra','codehilite','toc')
RICHTEXT_FILTER_LEVEL = 3
PAGEDOWN_SERVER_SIDE_PREVIEW = True- urls.py の設定
sudo vi /opt/blog/tenn25blog/tenn25blog/urls.py
以下を設定
# Add for Markdown
import mezzanine_pagedown.urls
urlpatterns += [
# For Markdown Preview
url("^pagedown/", include(mezzanine_pagedown.urls)),- 201811/19 追記
追加後にマークダウンプレビューが見れない問題があったが、
static ファイルの集約をし直して無いからだった。
(py36) [root@ip-10-0-0-51 tenn25blog]# python manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
/opt/blog/tenn25blog/static
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/pagedown/Markdown.Converter.js'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/pagedown/Markdown.Sanitizer.js'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/pagedown/Markdown.Editor.js'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/pagedown/wmd-buttons.png'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/pagedown/LICENSE.txt'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/css/pagedown.css'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/js/jquery.cookie.js'
Copying '/opt/blog/py36/lib64/python3.6/site-packages/mezzanine_pagedown/static/mezzanine_pagedown/js/jquery.ba-throttle-debounce.min.js'
Found another file with the destination path 'admin/js/actions.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/actions.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
8 static files copied to '/opt/blog/tenn25blog/static', 412 unmodified.Django プロジェクトを Lets Encrypt で HTTPS 化する#
AWS のセキュリティグループで 443 ポートを解放する。
certbot のインストール
必要だったらやる
$ sudo yum install epel-release
CertBotのインストール
$ sudo yum install certbot
$ pwd
/opt/blog/tenn25blog/static
$ ls
admin css filebrowser fonts grappelli img js media mezzanine robots.txt test
Djnagoの場合静的ファイルはstaticにまとめてるので、そこを指定する。
$ sudo vi /etc/nginx/conf.d/blog.conf
location /.well-known {
root /opt/blog/tenn25blog/static;
}
$ sudo certbot certonly --webroot -w /opt/blog/tenn25blog/static -d www.tenn25.com
規約に同意しますか→(A)gree
電子フロンティア財団からの連絡を受け取りますか→(N)o
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/www.tenn25.com/fullchain.pem
と出たらOK!!!- nginx.conf の設定
server {
listen 80;
server_name www.tenn25.com;
return 301 https://$host$request_uri;
}
server {
listen 443 default ssl;
server_name www.tenn25.com;
location = /favicon.ico {access_log off; log_not_found off;}
location /static/ {
root /opt/blog/tenn25blog;
}
location / {
include proxy_params;
proxy_pass http://app_server;
# proxy_pass http://localhost:8000;
}
location /.well-known {
root /opt/blog/tenn25blog/static;
}
ssl_certificate /etc/letsencrypt/live/www.tenn25.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.tenn25.com/privkey.pem;
}