Skip to content
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

I think it should be better to store images on a per post directory basis #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/jekyll-admin/server/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ class Server < Sinatra::Base

write_file write_path, document_body
delete_file(draft_path) if request_payload["published"]
ensure_assets_directory

json written_file.to_api(:include_content => true)
end

delete "/:collection_id/*?/?:path.:ext" do
ensure_requested_file
delete_file path
remove_assets_directory
content_type :json
status 200
halt
Expand Down Expand Up @@ -67,6 +69,26 @@ def ensure_directory
render_404 unless Dir.exist?(directory_path)
end


def ensure_assets_directory
unless Dir.exist?(assets_directory_path)
Dir.mkdir(assets_directory_path)
end
end

def remove_assets_directory
if Dir.exist?(assets_directory_path)
FileUtils.rm_rf(assets_directory_path)
end

end

def assets_directory_path
File.join( site.source, 'assets', 'posts', filename.gsub(/.md$/,'') )
end



def entries
args = {
:base => site.source,
Expand Down