Skip to content

書籍に載せるリンクと、GETリクエストを受け取るウェブ側のインターフェイスを決める #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 3, 2016

Conversation

tomoko523
Copy link
Contributor

@tomoko523 tomoko523 commented Nov 24, 2016

やりたいこと

書籍に載せるリンクをfixさせたい。

1.ニンジャのスプライト素材(読者にダウンロードしてもらう)
2.「発展課題」×6

cf. #16

やること

@tomoko523
Copy link
Contributor Author

tomoko523 commented Nov 24, 2016

パーマリンクについて調査

scrivitoの(Blog)のurlは「title-id」となっている(ex./test-39d537f2e14bb057)ため、ユーザーフレンドリーなurl(ex./test)にするにはパーマリンクを設定する必要がある。

#config/routes.rb
scrivito_route '(/)(*slug-):id', using: 'slug_id'
scrivito_route '/*permalink', using: 'permalink', format: false

1.コンソールから設定

https://scrivito.com/creating-a-blog-aa95279253d763be

irb(main):026:0> Scrivito::Workspace.current = Scrivito::Workspace.create(title: "Blog")
=> <Scrivito::Workspace id="637a5605b7e60e3a" title="Blog">
irb(main):027:0> BlogOverviewPage.create(_permalink: "blog")
=> <BlogOverviewPage id="0dfe05b066fd7131" path="">

2.画面から設定

https://scrivito.com/assigning-permalinks-to-pages-3742300d4eb67407

パーマリンクを設定したいviewに下記を追加すると、EditModeでパーマリンクが設定できるようになる。

<%= scrivito_details_for 'Permalink' do %>
  <%= scrivito_tag :div, @obj, :_permalink %>
<% end %>

課題

  • パーマリンク自体は「/」をいれた階層が設定できない __=> /から始まる文字列は入力できない
  • scrivito_route '/sotech-sha/:chapter/:section/*permalink', using: 'permalink', format: false
    のような書き方はできる
  • 画面ごとにパーマリンクを設定する必要がある?

書籍からのアクセスをリダイレクトするためのコントローラを追加した。
その他
・blog_post_pageの画像にclass追加
@tomoko523
Copy link
Contributor Author

tomoko523 commented Dec 1, 2016

階層構造のリンクが作成できないか調査

やりたかったこと

  1. /blog  →全コンテンツ一覧表示
  2. /blog/1 →各コンテンツ表示
  3. /sotechsha/1 →…/blog/1にリダイレクト

現状

  1. /blog  →全コンテンツ一覧表示
  2. /1 →各コンテンツ表示
  3. /sotechsha/1 →…/1にリダイレクト

検討内容

scrivito_route '/blog/*permalink', using: 'permalink', format: false

に設定した場合、1. が…blog/blogになってしまう、かつ他のページでパーマリンクを使用したい場合に影響がでると考えたため対象のページに全てパーマリンクを貼ることにしました。

@yasulab yasulab mentioned this pull request Dec 2, 2016
3 tasks
@yasulab
Copy link
Member

yasulab commented Dec 3, 2016

@tomoko523 とりあえず本に載せる内容と、そこから来たGETリクエストをコントローラーでリダイレクトする部分まではfixできたので、一旦ここでマージして、残りの実装は別のPRにしようかなと考えています🤔 どうですかね?

@tomoko523
Copy link
Contributor Author

@yasulab はい、そちらの対応で大丈夫です!

@yasulab
Copy link
Member

yasulab commented Dec 3, 2016

ではこちらはマージして、残りは別PRでまとめておきますね ;)

@yasulab yasulab changed the title [WIP] Blog詳細ページのカスタマイズを行う(書籍用) 書籍に載せるリンクと、GETリクエストを受け取るウェブ側のインターフェイスを決める Dec 3, 2016
@yasulab yasulab merged commit e2d690f into master Dec 3, 2016
@yasulab yasulab deleted the custom-book-page branch December 3, 2016 06:08
@yasulab
Copy link
Member

yasulab commented Dec 3, 2016

@tomoko523 関連するものはIssue/PRでまとめておきました〜 📑

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants