Giter Club home page Giter Club logo

spree_static_content's Introduction

⚠️ Deprecation notice ⚠️

Since Spree 4.3 this extension is deprecated and not needed. Spree 4.3 includes a built-in CMS system that surpasses this extension.

Spree Static Content

Build Status Code Climate

Good, clean content management of pages for Spree. You can use this to:

  • Add and manage static pages such as an 'About' page.
  • Show a static page instead of existing dynamic pages such as the home page, products pages, and taxon pages.

HowTo

Using the 'Pages' option in the admin tab, you can add static pages to your Spree install. The page content can be pulled directly from the database, be a separate layout file or rendered as a partial.

In the admin tab, use the 'New page' option to create a new static page.

The title, slug, body, and meta fields will replace their respective page elements on load. The title, slug and body element are all required fields.

Body text provided without a layout / partial being specified will be loaded in the spree_application layout after it is pulled from the database.

Layout and Partial Rendering

To render an entire page without the spree_application layout, specify a relative path to the layout file (eg. spree/layouts/layout_file_name). This file will not be prefixed with an underscore as it is a layout, not a partial.

To render a partial, specify the path in the layout file name and check the 'Render layout as partial' option. The path specified in the layout area will not have an underscore, but it will be required in the filename.

Also note the availability of the render_snippet helper which finds a page by its slug and renders the raw page body anywhere in your view.

Options

Use the 'Show in' checkboxes to specify whether to display the page links in the header, footer or sidebar. The position setting alters the order in which they appear.

Finally, toggle the visibility using the 'Visible' checkbox. If it is unchecked, the page will not be available.


Installation

  1. Add this extension to your Gemfile with this line:

Spree >= 3.1

gem 'spree_static_content', github: 'spree-contrib/spree_static_content'

Spree 3.0 and Spree 2.x

gem 'spree_static_content', github: 'spree-contrib/spree_static_content', branch: 'X-X-stable'

The branch option is important: it must match the version of Spree you're using. For example, use 3-0-stable if you're using Spree 3-0-stable or any 3.0.x version.

  1. Install the gem using Bundler:
bundle install
  1. Copy & run migrations
bundle exec rails g spree_static_content:install
  1. Restart your server

If your server was running, restart it so that it can find the assets properly.


Contributing

See corresponding guidelines


Copyright (c) 2008-2015 Peter Berkenbosch and contributors, released under the New BSD License

spree_static_content's People

Contributors

bbonislawski avatar bregor avatar damianlegawiec avatar eliotsykes avatar ethier avatar futhr avatar geekoncoffee avatar hates avatar iloveitaly avatar jdutil avatar johanb avatar joren avatar kacpermekarski avatar laurens avatar lbrapid avatar mauazua avatar nikolaenkov avatar nishant-cyro avatar odk211 avatar peterberkenbosch avatar pex avatar priidikvaikla avatar radar avatar raulpopadineti avatar romul avatar rterbush avatar schof avatar shopjoy avatar swistak avatar tgmcclen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spree_static_content's Issues

Feature Requests: Change layout path access / change visibility toggle

Perhaps I am missing how I spree_static_content works, but I was unable to use spree/layouts/my_layout as a path.
Seems that app/views/layouts is wired in. This is fine, but for me app/views/spree/layouts works better for my paths.

Other point is in regard to the interface. Default functionality seems to be checkbox to select where you want a link to appear. The visibility checkbox turns off the visibility of the link AND the availability of the page. When you just want to
have some static menu items, this is more work because now you have to go in and hide visibility of the generated link.

Seems would be better to have 2 switches: One to turn off link, the other to turn off page availability.

...of course this may all be available now, but I did not discover it even after checking out the video.

Thanks! Jet

I am really liking this extension!

DEPRECATION WARNING: <% %> style block helpers are deprecated. Please use <%= %>.

Rails 3.0.9 prints warning in log for spree_static_content/app/views/admin/pages/edit.html.erb.

I think problem in following code:

<% semantic_form_for([:admin, @page]) do |f| -%>
  <%= render :partial => "form", :locals => { :f => f } %>
  <p class="form-buttons">
    <%= button t("actions.update"), nil, 'submit' %>
    <%= t("or") %> <%= link_to t("actions.cancel"), admin_pages_path %>
  </p>
<% end %>

It should change the line
<% semantic_form_for([:admin, @page]) do |f| -%>
to
<%= semantic_form_for([:admin, @page]) do |f| -%>

Heroku mri-1.9.2 + v6.0.2 + spree 0.60.1

I am using spree + heroku + static_content and i am getting this error trying to enter the admin.
ActionView::Template::Error (undefined method `upcase' for nil:NilClass):
<%= tab(:pages) %>

I guess that it is the ruby version but i am lost of what change do i have to do to make this work, in development i am using ruby 1.9.2p180 and it's working perfect

Thank you!

Lack of "how to use" page in wiki

Unlike what you mentioned in the Readme file,
The wikipage is lack of content regarding how to use the spree_static_content repo.

Layout not reloaded in production.

I am using this extension with no explicit layout defined, so it's using the default app layout. In production environment, when I make changes to say footer or head and then restart my app to reload the templates, pages that were created with this extension will not pick up the changes and will use old layout. To fix this I have to go into the Admin - Pages section and manually "Update" (without changing anything) each page so it refreshes, this can become quickly frustrating if there are multiple pages.

Not quite sure what would be the best approach to handling this issue, either add an "Refresh All" button or change something that would automatically refresh when app is restarted.

Static pages give 404, query is missing leading slash?

Updating to the latest spree_static_content, static pages no longer load. I think this is due to the leading slash from the slug not being included in the query.

Extract from Gemfile.lock

GIT
remote: git://github.com/spree/spree_static_content
revision: dbd57c5
branch: master
specs:
spree_static_content (1.1.0.beta)
spree_auth (> 1.1.0.beta)
spree_core (
> 1.1.0.beta)

Development log with lastest spree_static_content that is failing
notice the difference: spree_pages.slug = 'kitchens/ducting'

Started GET "/kitchens/ducting" for 127.0.0.1 at 2012-04-06 16:21:55 +0100
(0.4ms) SELECT COUNT() FROM spree_pages WHERE spree_pages.visible = 1 AND spree_pages.slug = '/kitchens/ducting'
Processing by Spree::StaticContentController#show as HTML
Parameters: {"path"=>"kitchens/ducting"}
Spree::User Load (0.3ms) SELECT spree_users.
FROM spree_users WHERE spree_users.id = 1 LIMIT 1
Spree::Page Load (0.3ms) SELECT spree_pages.* FROM spree_pages WHERE spree_pages.visible = 1 AND spree_pages.slug = 'kitchens/ducting' ORDER BY position ASC LIMIT 1
Rendered public/404.html (0.0ms)
Completed 404 Not Found in 6ms (Views: 3.5ms | ActiveRecord: 0.6ms)
^C[2012-04-06 16:23:14] INFO going to shutdown ...
[2012-04-06 16:23:14] INFO WEBrick::HTTPServer#start done.
Exiting

Development log when reverted to previous spree_static_content and is working
notice: spree_pages.slug = '/kitchens/ducting'

1.9.3@rkbbspree steve@Steve-Root-MBP:rkbbspree$rails s
=> Booting WEBrick
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-04-06 16:23:22] INFO WEBrick 1.3.1
[2012-04-06 16:23:22] INFO ruby 1.9.3 (2012-02-16) [x86_64-darwin11.3.0]
[2012-04-06 16:23:22] INFO WEBrick::HTTPServer#start: pid=10212 port=3000

Started GET "/kitchens/ducting" for 127.0.0.1 at 2012-04-06 16:23:27 +0100
(0.3ms) SELECT COUNT() FROM spree_pages WHERE spree_pages.visible = 1 AND spree_pages.slug = '/kitchens/ducting'
Processing by Spree::StaticContentController#show as HTML
Parameters: {"path"=>"kitchens/ducting"}
Spree::User Load (0.3ms) SELECT spree_users.
FROM spree_users WHERE spree_users.id = 1 LIMIT 1
Spree::Page Load (0.4ms) SELECT spree_pages.* FROM spree_pages WHERE spree_pages.visible = 1 AND spree_pages.slug = '/kitchens/ducting' ORDER BY position ASC LIMIT 1
Deface: 13 overrides found for 'spree/layouts/spree_application'
...and it continues to completion...

Gemfile, :branch => "master" breaks with bundle install

In my Gemfile calling

gem 'spree_static_content',
:git => 'git://github.com/spree/spree_static_content',
:branch => 'master'

running bundle install gives the following error.

Git error: command git clone '[email protected]:spree/spree_static_content.git' "/home/deployer/.rvm/gems/ruby-1.9.3-p194/cache/bundler/git/spree_static_content-5257911d378d517865892452162b4fa6dc31175f" --bare --no-hardlinks in directory /home/deployer/store has failed.

Can't compile gem

Hi everysoul!

When i trying to compile this gem into my spree environment, i get a this message from bundler:

slon@srv01:/im/app1/mystore$ bundle install --no-deployment
Updating git://github.com/spree/spree_static_content
Fetching gem metadata from https://rubygems.org/..
Bundler could not find compatible versions for gem "spree_core":
In Gemfile:
spree_static_content (>= 0) ruby depends on
spree_core (
> 1.2.0.beta) ruby

spree_core (1.1.3)

I think, that a gem need the spree_core 1.2.0.beta, but i have a spree_core 1.2.0.rc1 and when try to "gem install spree_core -v '1.2.0.beta'" - then got a this message:

slon@srv01:~/im/app1/mystore$ gem install spree_core -v '1.2.0.beta'
ERROR: Could not find a valid gem 'spree_core' (= 1.2.0.beta) in any repository
ERROR: Possible alternatives: spree_core

Can you explain how to i must install it. With best regards...

Showing a static page instead of existing dynamic pages

Hi there,

I can happily add and manage static pages such as an 'About' page, but if I try to show a static page instead of an existing dynamic page such as the home page - the dynamic page does not get replaced.

Ruby 1.9.3
Rails 3.1.3
Spree 1.0.0
Spree_static_content 1.0.0 from git://raw.github.com/spree/spree_static_content.git (at master)

Many thanks

1.2 had helper, 1.3 doesn't - not sure if that's right

Hi

In 1.2, controller had a helper added
89a230d
I'm just upgrading to 1.3 and getting an error ActionView::Template::Error (undefined local variable or methodget_taxonomies' `

I noticed that the helper isn't called in the 1.3 branch. I added it directly to my gem and it solved this problem but I was presented with another. As a newbie I'm not sure if the helper will will solve my problem or not but I thought I'd mention it in case it's important. Just close this issue if it's not necessary.

memcached cache_store error

If I use memcached as my cache_store then I get the following error when trying to create a new page.

undefined method `model_name' for NilClass:Class

Extracted source (around line # 4):

4: <%= semantic_form_for([:admin, @page]) do |f| %>
5:   <%= render :partial => "form", :locals => { :f => f } %>

Mass assignment issue in spree_static_content

When creating a new page an error is generated:

Can't mass-assign protected attributes: title, slug, body, meta_title, meta_keywords, meta_description, layout, foreign_link, position, show_in_sidebar, show_in_header, show_in_footer, visible

I've tried to update the models/spree/page.rb file to include attr_accessible for those attributes, but it is not working:

attr_accessible :title, :slug, :body, :meta_title, :meta_keywords, :meta_description, :layout, :foreign_link, :position, :show_in_sidebar, :show_in_header, :show_in_footer, :visible

Slug error in 1.2

Just installed this extension in Spree 1.2.0 using branch 1-2-stable, but I get a 404 error when visiting a created About page with the "about" slug (http://localhost:3000/about), this is the query:

 SELECT `spree_pages`.* FROM `spree_pages` WHERE `spree_pages`.`visible` = 1 AND ((`spree_pages`.`slug` = '/about' OR `spree_pages`.`slug` = '//about')) ORDER BY position ASC LIMIT 1

If I use "/about" as slug, the page can be normally opened

Question about Pushing to Heroku

I have spree running on heroku. And I just got Spree_Static_Content Running great on Localhost. (Thank you)

Hoever, I am now running into an issue with trying to push to heroku. It seems to be hanging up on this gem.

Below is the Log. If anyone knows a workaround it would be greatly appreciated.

Counting objects: 96, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (56/56), done.
Writing objects: 100% (72/72), 267.89 KiB | 225 KiB/s, done.
Total 72 (delta 22), reused 0 (delta 0)

-----> Heroku receiving push
-----> Removing .DS_Store files
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Fetching [email protected]:spree/spree_static_content.git
Host key verification failed.
fatal: The remote end hung up unexpectedly
Git error: command git clone '[email protected]:spree/spree_static_content.git' "/tmp/build_l959i6b5oj74/vendor/bundle/ruby/1.9.1/cache/bundler/git/spree_static_content-5257911d378d517865892452162b4fa6dc31175f" --bare --no-hardlinks in directory /tmp/build_l959i6b5oj74 has failed.
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app

Thanks!

Generates sidebar even when no menu items available

When enabled tis module the sidebar always displayed in my theme because of the empty #sidebar-pages-menu nav element. Added a fix to the view template.

# app/views/spree/static_content/_static_content_sidebar.html.erb
<% if Spree::Page.visible.sidebar_links.any? %>
  <nav id="sidebar-pages-menu">
    <ul><%= render :partial => "spree/static_content/static_content_list", :collection => Spree::Page.visible.sidebar_links, :as => :page %></ul>
  </nav>
<% end %>

Travis is not running specs.

New commits are not being tested by Travis... Has the hook been turned off for the repo? Last build was 4 months ago.

undefined method `render_layout_as_partial?' for #<Spree::Page>

4202c16

The commit introduced a boolean column 'render_layout_as_partial' but the references in the commit try to access the idiomatic 'render_layout_as_partial?', diff being the trailing question mark.

Need either an instance method, or changed references.

Tell me which is better and I can shoot a pull request.

route not found issue

Using spree 1.1.1
spree static content branch 1.1-stable
rails 3.2.3

When I save a static page and then I navigate to the link, I get a route not found error?

is this a known issue or just happing to me?

thanks,
-Mez

1-0-stable: routing(?) issue in production

Hallo!

I have a problem running it in production. I've being always redirected to first saved page as I try to call any other saved static pages.

Have somebody a similar problem?

thanks in advance!

Upgrading to spree 1.1.3 --> NoMethodError in Spree/static_content#show

Looks like upgrading to spree 1.1.3 breaks the static content extension. You will get the following error:

undefined method `get_taxonomies' for #Spree::StaticContentController:0x007f899a9afbe8

Extracted source (around line #2):

1:
2: <% get_taxonomies.each do |taxonomy| %>
3:

<%= t(:shop_by_taxonomy, :taxonomy => taxonomy.name.singularize) %>

4: <%= taxons_tree(taxonomy.root, @Taxon, Spree::Config[:max_level_in_taxons_menu] || 1) %>
5: <% end %>
I am using the master branch for spree_static_content and spree 1.1.3 in my gemfile.

Cache includes shopping cart

The cache seems to include the shopping cart (in the menu in my case) and is not updated when adding/removing products to the cart. It seems to only be in production mode and I'm running Apache 2 and Passenger.

To reproduce:

  1. Create new page
  2. View static page. Cart is empty.
  3. Go to products and add product. Cart updated with 1 product
  4. View the same static page. Cart is empty.

Fragment Cache problem

hi There,

i know in the latest version those fragment has been removed from Spree::Admin::PagesController

i just want to share what i found, i think the problem before was missing '/'

Cache delete: views/spree_static_contentshop-returns-policy_spree_static_content
Expire fragment views/spree_static_contentshop-returns-policy_spree_static_content

Read fragment views/spree_static_content/shop-returns-policy_spree_static_content (0.6ms)

Cheers
Wedy

fec35c3af6 & 06279837f6 Breaks spree

Commit fec35c3 & 0627983 breaks default configuration of spree. While developing with a Gemfile of:

gem 'spree'
gem 'spree_static_content', :git => 'git://github.com/spree/spree_static_content.git'

The latest commit assumes that spree is also running off the HEAD from the spree/spree repository. This is bad seeing as the gem on rubygems.org is old.

Root path not properly overridden.

Hello, I ran into a small issue while installing this extension with spree 1.0.0.rc2

With a page that has a slug of '/', the root page is still /products (spree default). Ive used this extension with previous versions of spree and it worked great.

ruby 1.9.2
rails 3.1.1
spree 1.0.0.rc2
'spree_static_content', ' 1.0.0

Thank you.

in Gemfile, :branch => "master" isn't working

This could be me.... but

If I use this in my Gemfile

gem 'spree_static_content',
        :git => 'git://github.com/spree/spree_static_content',
        :branch => 'master'

running 'bundle install' gives me:
Updating git://github.com/spree/spree_static_content
fatal: Could not parse object 'b853a62c7cdf67973661af8391aa8e1a3f68966f'.
Git error: command git reset --hard b853a62c7cdf67973661af8391aa8e1a3f68966f in directory /Users/steve/.rvm/gems/ruby-1.9.3-p0@rkbbspree/bundler/gems/spree_static_content-b853a62c7cdf has failed.
If this error persists you could try removing the cache directory '/Users/steve/.rvm/gems/ruby-1.9.3-p0@rkbbspree/cache/bundler/git/spree_static_content-ecb33487986dcb19dba1425cbbb89a27abdbde7a'

however, if I have this in my Gemfile:

gem 'spree_static_content',
        :git => 'git://github.com/spree/spree_static_content',
        :branch => 'namespace'

Then everything works.

No issue but recomendation

I've changed the default layout for Spree, but when I create a new static page it defaults to the original Spree layout. I found here: https://github.com/spree/spree_static_content/blob/master/app/controllers/spree/static_content_controller.rb

This:

    def determine_layout
        return @page.layout if @page and @page.layout.present? and not @page.render_layout_as_partial?
        'spree/layouts/spree_application'
    end

So I'm overriding this for my project with:

    def determine_layout
        return @page.layout if @page and @page.layout.present? and not @page.render_layout_as_partial?
        Spree::Config.layout
    end

I'm new to all this, so I don't know if this is the right way to do it but it would be a good improvement.

root path is not overridden in development mode

ruby 1.9.2
rails 3.0.9
spree 0.60.1
'spree_static_content', '~> 0.60.1'

With a page that has a slug of '/', when in development mode, the root page is still /products (spree default), but in production mode, root path is properly overridden.

Instructions not working well

It says in the instructions (README):

gem 'spree_static_content', :git => '[email protected]:spree/spree_static_content.git', :branch => '1-1-stable'

But it didn't work for me, I had to change that to:

gem 'spree_static_content', :git => 'git://github.com/spree/spree_static_content.git', :branch => '1-1-stable'

Routing error on localhost

I am putting /about_us in the stub field, but when I try to go to localhost:8080/about_us it gives a routing error: No route matches [GET] "/about_us"

There is not a whole lot of explanation on how to use this extension, so am I doing it wrong? I am using spree 1-1-stable and static content 1-1-stable.

Caching and expiring pages

Since I just fixed the remaining cache-key-name problem, and I'm working with this on a new site, I'm discovering a process issue. Suppose the following:

  1. I go in and add a few static pages A and B, and add them to the header.
  2. People visit the site, pages A and B get cached as expected.
  3. I then add a new static page C, and also add it to the header.

Now when people request page C, everything looks great and the header has A, B, and C.

But when people request pages A or B, there are still cached versions of those pages that don't have page C in the header, since the header is part of what's cached.

I can think of a few ways to fix this:

  1. We could use fragment caching and only cache the page content, excluding all of the layout.
  2. We could expire ALL of the cached pages whenever any page is edited (we currently just expire the page that was edited)
  3. We could have a button on the Admin/Pages tab to expire all pages.

Any thoughts?

Formtastic mentioned in install, another commit says we don't use it anymore

This hasn't caused me any problems, but I thought I'd mention it in case it is a problem waiting to bite someone.

Install generator https://github.com/spree/spree_static_content/blob/master/lib/generators/spree_static_content/install_generator.rb

includes the following

        def add_stylesheets
          inject_into_file "app/assets/stylesheets/admin/all.css", " *= require formtastic\n", :before => /\*\//, :verbose => true
        end

However I also noticed this more recent commit
2e6dbc9
updating https://github.com/spree/spree_static_content/blob/master/lib/spree_static_content.rb

says 'we dont use formtastic anymore'

Italian translation

The italian locale:

---
it:
  activerecord:
    attributes:
      page:
        title: Titolo
        slug: Slug
        body: Testo
        foreign_link: Link esterni (URL)
        show_in_sidebar: Mostra nella sidebar
        show_in_header: Mostra nell'header
        show_in_footer: Mostra nel footer
        position: Posizione
        visible: Visibile
        meta_keywords: Meta Keywords
        meta_description: Meta Description
        layout: Layout
    models:
      page:
        one: Pagina
        many: Pagine

  page: Pagina
  pages: Pagine
  static_content:
    static_pages: Pagine statiche
    static_pages_desc: Gestisce le pagine statiche con un editor WYSIWYG.
    new_page: Nuova pagina
    editing_page: Modifica pagina
    confirm_delete: Sei sicuro?
    link: Link
    meta_title: Meta Title

Migration to rename table from pages to spree_pages missing?

I just tried installing this on 1.1.3 and ran the installation command and tried running the migrations afterwards. It errored out with the below message. I manually renamed the table spree_pages from pages and reran the migrations and it worked.

== AddRenderAsPartialForLayoutForSpreePages: migrating =======================
-- column_exists?(:spree_pages, :render_layout_as_partial)
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'spree113_development.spree_pages' doesn't exist: SHOW FULL
FIELDS FROM spree_pages

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Unable to use layouts

Using spree 1.0.0, rails 3.1.1, and including spree_static_content from master in gemfile.

I've created a layout in app/views/layouts, and told a static page to use it in spree admin. The page doesn't use the specified layout. This worked fine in older versions of spree but I now can't get any pages to use layouts.

I've had a look around this gem and spree but I'm not familiar enough with rails/spree to figure out why it's happening :(

Page routing not working

Hi, I am using Spree 1.0.2 and your spree_static_content extension, but I cannot get any of the pages to load. I keep getting a routing error, where rails cannot find the route to any page.

I was wondering if this is a common problem, or if I may have done something wrong.... the installations instructions are a bit slim.

Thanks in advance for your time,
JD

Sidebar menu doesnt show up on static pages

Can't get the sidebar menu to show up on static pages. Shows up on front page. Can it be that

<div data-hook="homepage_sidebar_navigation">

is missing in _sidebar.html.erb in Spree 1.2.x?

Add Partial Support

It would be great if there was a way to insert a partial into the page body. This would allow static page to show information that may need to be calculated in real time and be able to reuse some content that is already available through other partials.

No 'Render as a partial' option

It says you can render content as a partial by checking the 'Render layout as partial' option, but I can't see that option.

Bad routes problems

I am using the spree_static_content 1.3.2-stable branch.
I have my Spree mounted at '/store'

Now I get urls like http://localhost:3000/storeabout-us instead of http://localhost:3000/about-us

What am I doing wrong?

Leading slash required in slug is confusing.

Here is a situation that I recently ran into that I found very confusing:

  1. Create a page with the slug "test-page" and make it appear in the header.
  2. Create a product and navigate to the product under "/products/product-name".
  3. Try and click on the Test Page link in the header.
  4. Watch as you are navigated to "/products/test-page" instead of "/test-page" like you expected and get a 404 error.

This situation is remedied by making sure that you place a leading slash in the slug; so that "test-page" would become "/test-page" in the slog slot on the Page creation section.

This seems confusing because I do not expect to have to put the slug in. Here are my potential solutions:

  1. Write a warning on the Page creation page that tells people that they probably want to put a leading forward slash in place so that the slug is at one constant url.

  2. (Preferred) Modify the code to always put a leading slash in place:

    <% page_uri = Rails.application.routes.named_routes[:spree].path.spec.to_s == '/' ? '/' + page.slug : Rails.application.routes.named_routes[:spree].path.spec.to_s + page.slug %>

That would probably work. The file is _static_content_list.html.erb

Either way it would be really good to be able to specify that you actually did mean to use the root endpoint. Even an option in the page creation would help with this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.