Class: FluidCLI::Theme::Navigation::RouteNavigator
- Inherits:
-
Object
- Object
- FluidCLI::Theme::Navigation::RouteNavigator
- Defined in:
- lib/fluid_cli/theme/navigation/route_navigator.rb
Constant Summary collapse
- STATIC_ROUTES =
[ { label: "Home", path: "/home" }, { label: "Shop", path: "/home/shop" }, { label: "Join / Sign Up", path: "/home/join" }, { label: "Cart", path: "/cart" }, { label: "Blog", path: "/home/blog" }, { label: "Categories (all)", path: "/home/categories" }, { label: "Collections (all)", path: "/home/collections" }, ].freeze
- RESOURCE_ROUTES =
[ { label: "Category", themeable_type: "category", path_template: "/home/categories/%<id>s", fallback_path: "/home/categories" }, { label: "Collection", themeable_type: "collection", path_template: "/home/collections/%<id>s", fallback_path: "/home/collections" }, { label: "Product", themeable_type: "product", path_template: "/home/products/%<id>s", fallback_path: "/home/shop" }, { label: "Library", themeable_type: "library", path_template: "/home/libraries/%<id>s", fallback_path: "/home/libraries" }, { label: "Post", themeable_type: "post", path_template: "/home/posts/%<id>s", fallback_path: "/home/blog" }, { label: "Media", themeable_type: "medium", path_template: "/home/media/%<id>s", fallback_path: "/home/media" }, { label: "Enrollment Pack", themeable_type: "enrollment_pack", path_template: "/home/enrollments/%<id>s", fallback_path: "/home/join" }, ].freeze
Instance Method Summary collapse
-
#initialize(ctx, address, theme_id) ⇒ RouteNavigator
constructor
A new instance of RouteNavigator.
- #navigate ⇒ Object
Constructor Details
#initialize(ctx, address, theme_id) ⇒ RouteNavigator
Returns a new instance of RouteNavigator.
27 28 29 30 31 |
# File 'lib/fluid_cli/theme/navigation/route_navigator.rb', line 27 def initialize(ctx, address, theme_id) @ctx = ctx @address = address @theme_id = theme_id end |
Instance Method Details
#navigate ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluid_cli/theme/navigation/route_navigator.rb', line 33 def navigate path = select_destination return unless path url = "#{@address}#{path}" @ctx.puts("\n{{bold:Navigate to: {{green:#{url}}}}}\n") open_browser(url) rescue => e @ctx.debug("Navigation error: #{e.}") end |