This commit is contained in:
Scott Chacon 2014-10-26 20:38:39 +01:00
Родитель 33aaee834d
Коммит 21632d44eb
2 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -1,4 +1,5 @@
class BooksController < ApplicationController
skip_before_filter :verify_authenticity_token, only: [:update]
before_filter :book_resource, only: [:section, :chapter]
before_filter :redirect_book, only: [:show]
@ -65,6 +66,24 @@ class BooksController < ApplicationController
render 'section'
end
def update
if params[:token] == ENV['UPDATE_TOKEN']
build = params[:build]
if book = Book.where(:code => build[:code], :edition => build[:edition].to_i).first
book.ebook_pdf = build[:download][:pdf]
book.ebook_epub = build[:download][:epub]
book.ebook_mobi = build[:download][:mobi]
book.ebook_html = build[:download][:html]
book.processed = true
book.percent_complete = build[:percent].to_i
book.save
end
render :text => 'OK'
else
render :text => 'NOPE - AUTH'
end
end
private
def redirect_book

Просмотреть файл

@ -44,6 +44,7 @@ Gitscm::Application.routes.draw do
get "/:lang" => "books#show", as: :lang
get "/:lang/:slug" => "books#section"
end
post "/update" => "books#update"
get "/download" => "downloads#index"
get "/download/:platform" => "downloads#download"
@ -69,10 +70,9 @@ Gitscm::Application.routes.draw do
get "/blog.rss" => "blog#feed"
get "/blog" => "blog#index"
get "/publish" => "doc#book_update"
get "/publish" => "doc#book_update"
post "/related" => "doc#related_update"
get "/about" => "about#index"
get "/about/:section" => "about#index"