lib/lookbook/utils.rb in lookbook-0.9.8 vs lib/lookbook/utils.rb in lookbook-1.0.0.beta.0
- old
+ new
@@ -1,19 +1,21 @@
module Lookbook
module Utils
+ include Lookbook::Engine.routes.url_helpers
+
POSITION_PREFIX_REGEX = /^(\d+?)[-_]/
FRONTMATTER_REGEX = /\A---(.|\n)*?---/
protected
def generate_id(*args)
- parts = args.map { |arg| arg.to_s.force_encoding("UTF-8").parameterize.underscore }
- parts.join("-").tr("/", "-").tr("_", "-").delete_prefix("-").delete_suffix("-").gsub("--", "-")
+ parts = args.map { |arg| arg.to_s.parameterize.underscore }
+ parts.join("-").tr("/_", "-").delete_prefix("-").delete_suffix("-").gsub("--", "-")
end
def preview_class_basename(klass)
- class_name(klass).to_s.chomp("ComponentPreview").chomp("Component::Preview").chomp("::Preview").chomp("Component").chomp("::")
+ class_name(klass).to_s.chomp("ComponentPreview").chomp("Component::Preview").chomp("::Preview").chomp("Component").chomp("Preview").chomp("::")
end
def preview_class_name(klass)
preview_class_basename(klass).underscore
end
@@ -46,9 +48,15 @@
path.split("/").map { |segment| remove_position_prefix(segment) }.join("/")
end
def to_preview_path(*args)
args.flatten.map { |arg| preview_class_name(arg) }.join("/")
+ end
+
+ protected
+
+ def default_url_options
+ {}
end
private
def parse_frontmatter(content)