noumenon 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 0.2.2
2
+
3
+ ## New Features
4
+
5
+ * By default the `send_file` method is used to serve assets from the asset repository so that caching
6
+ is handled correctly.
7
+
8
+ ## Bug Fixes
9
+
10
+ * The asset repository was replacing the content repository entirely in new Noumenon sites.
11
+ * Removed asset management methods from the ContentRepository class.
12
+
1
13
  # 0.2.1
2
14
 
3
15
  ## New Features
@@ -2,6 +2,6 @@ require 'noumenon'
2
2
 
3
3
  Noumenon.theme = Noumenon::Theme.load("./theme")
4
4
  Noumenon.content_repository = Noumenon::ContentRepository::FileSystem.new(path: "./content/pages")
5
- Noumenon.content_repository = Noumenon::AssetRepository::FileSystem.new(path: "./content/assets")
5
+ Noumenon.asset_repository = Noumenon::AssetRepository::FileSystem.new(path: "./content/assets")
6
6
 
7
7
  run Noumenon.server
@@ -82,29 +82,6 @@ class Noumenon::ContentRepository::FileSystem < Noumenon::ContentRepository
82
82
  }.sort { |a, b| a[:path] <=> b[:path] }
83
83
  end
84
84
 
85
- # Save a static asset to the repository.
86
- #
87
- # @see Noumenon::Repository#save_asset
88
- # @api public
89
- def save_asset(path, content)
90
- raise ArgumentError.new("Assets must have a file extension.") unless File.extname(path).size > 0
91
- write_file File.join("assets", path), content
92
- end
93
-
94
- # Retreive a static asset to the repository.
95
- #
96
- # @see Noumenon::Repository#get_asset
97
- # @api public
98
- def get_asset(path)
99
- return nil unless File.extname(path).size > 0
100
- read_file File.join("assets", path)
101
- end
102
-
103
- def get_asset_path(path)
104
- return nil unless File.extname(path).size > 0
105
- repository_path "assets/#{path}"
106
- end
107
-
108
85
  private
109
86
  # Return the on-disk path to a repository item.
110
87
  def repository_path(path)
@@ -60,35 +60,6 @@ class Noumenon::ContentRepository
60
60
  def children(root = "/", depth = 1)
61
61
  not_supported "listing children from a path"
62
62
  end
63
-
64
- # Saves a static asset to the repository. To be saved the asset must have a file extension, to prevent
65
- # problems with an entire directory being overridden by a single asset.
66
- #
67
- # @param [ String ] path The path to save the asset at.
68
- # @param [ String ] content The contents of the asset.
69
- # @raises [ ArgumentError ] The path did not have a file extension.
70
- def save_asset(path, content)
71
- not_supported "saving assets"
72
- end
73
-
74
- # Retrieves a static asset from the repository. If the asset does not exist nil is returned.
75
- #
76
- # @param [ String ] path The path to load from.
77
- # @return [ String, nil ] The asset's content, or nil if it does not exist.
78
- def get_asset(path)
79
- not_supported "loading assets"
80
- end
81
-
82
- # Returns a URL for the specified asset, without checking for it's existence.
83
- #
84
- # This is most useful for repositories that save their assets to a CDN such as S3, and allows them to be
85
- # directly accessed from there, instead of downloaded and then retransmitted.
86
- #
87
- # @param [ String ] path The asset path within the repository.
88
- # @return [ String ] The URL to use when requesting the asset.
89
- def asset_url(path)
90
- File.join("/assets", path)
91
- end
92
63
 
93
64
  protected
94
65
  def not_supported(action)
data/lib/noumenon/core.rb CHANGED
@@ -52,11 +52,7 @@ class Noumenon::Core < Sinatra::Base
52
52
  asset = Noumenon.asset_repository.get(path)
53
53
  halt 404, "Asset not found" unless asset
54
54
 
55
- status 200
56
- headers \
57
- "Content-Type" => Rack::Mime.mime_type(File.extname(path)),
58
- "Length" => asset.bytesize.to_s
59
- body asset
55
+ send_file asset
60
56
  end
61
57
 
62
58
  get "*" do |path|
@@ -1,5 +1,5 @@
1
1
  module Noumenon
2
2
  # The current version of Noumenon.
3
3
  # @api public
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: noumenon
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jon Wood
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-08 00:00:00 +01:00
13
+ date: 2011-06-11 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency