Giter Site home page Giter Site logo

solidusio-contrib / solidus_static_content Goto Github PK

View Code? Open in Web Editor NEW
21.0 14.0 41.0 673 KB

:page_facing_up: Content management for your Solidus store.

License: BSD 3-Clause "New" or "Revised" License

Ruby 68.42% CSS 0.73% HTML 25.56% Shell 5.28%
solidus cms content-management extension static content

solidus_static_content's Introduction

Solidus Static Content

CircleCI

A fork of the Spree extension for compatibility with Solidus.

Good, clean content management of pages for Solidus. You can use it 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.

Installation

Add solidus_static_content to your Gemfile:

gem 'solidus_static_content'

Bundle your dependencies and run the installation generator:

bundle
bundle exec rails g solidus_static_content:install

Usage

Using the 'Pages' option in the admin tab, you can add static pages to your Solidus store. The page content can be pulled directly from the database, be a separate layout file or be 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 (e.g. spree/layouts/layout_file_name). Note that the name of 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.

Development

Testing the extension

First bundle your dependencies, then run bin/rake. bin/rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using bin/rake extension:test_app.

bundle
bin/rake

To run Rubocop static code analysis run

bundle exec rubocop

When testing your application's integration with this extension you may use its factories. Simply add this require statement to your spec_helper:

require 'solidus_static_content/factories'

Running the sandbox

To run this extension in a sandboxed Solidus application, you can run bin/sandbox. The path for the sandbox app is ./sandbox and bin/rails will forward any Rails commands to sandbox/bin/rails.

Here's an example:

$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop

Releasing new versions

Your new extension version can be released using gem-release like this:

bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release

License

Copyright (c) 2014 Peter Berkenbosch and contributors, released under the New BSD License.

solidus_static_content's People

Contributors

aitbw avatar aldesantis avatar alexblackie avatar bregor avatar dependabot-preview[bot] avatar elia avatar eliotsykes avatar ethier avatar futhr avatar geekoncoffee avatar iloveitaly avatar jdutil avatar jhawthorn avatar johanb avatar joren avatar jtapia avatar kennyadsl avatar lbrapid avatar memotoro avatar nikolaenkov avatar peterberkenbosch avatar pex avatar priidikvaikla avatar quintinadam avatar radar avatar romul avatar rterbush avatar schof 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

Watchers

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

solidus_static_content's Issues

Integration with headless CMS

It would be really great if solidus_static_content also allowed you to pull content from a headless CMS such as Contentful or Prismic, e.g. by leveraging Renderful.

I imagine that we could implement an adapter-based approach such as:

SolidusStaticContent.configure do |config|
  # Design pages in the Solidus backend (current approach).
  config.adapter = SolidusStaticContent::Adapter::Static.new

  # Retrieve pages through Renderful.
  config.adapter = SolidusStaticContent::Adapter::Renderful.new(client: renderful)
end

Then, in the backend UI, admins would be able to either:

  1. enter the page's content through the WYSIWYG editor, if they are using the Static adapter, or
  2. choose a content entry from the ones available in the headless CMS, if they are using the Renderful provider.

This would give Solidus store owners full flexibility as to where and how they want to store and manage their content.

Problem with solidus 2.1.0.beta1 and solidus_static_content

I have error running solidus store in frontend and in pages section.
I think is due to solidus version 2.1.0.beta1 because I created a new solidus store to test only with solidus_static_content and get the same error.

ActiveRecord::StatementInvalid in Spree::StaticContentController#show
PG::UndefinedTable: ERROR: relation "spree_pages" does not exist LINE 8: WHERE a.attrelid = '"spree_pages"'::regclass ^ : SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod, (SELECT c.collname FROM pg_collation c, pg_type t WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation), col_description(a.attrelid, a.attnum) AS comment FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"spree_pages"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum

Migrations not running

Calling the generator updates the frontend css file but doesn't run migrations. Manually trying to run the railties and migrate commands don't do anything either. Any ideas?

Page not found if store isn't mounted at the root

If I mount my store at /shop and the create a static page with the slug about and then visit that page I get the following error;

ActionController::RoutingError (No route matches [GET] "/shop/about")

Version conflict on newest version (deface compatibility)

Installing latest solidus and the solius_static_content extension leads to

Bundler could not find compatible versions for gem "deface":
  In snapshot (Gemfile.lock):
    deface (= 1.5.3)

  In Gemfile:
    solidus_auth_devise was resolved to 2.4.0, which depends on
      deface (~> 1.0)

    solidus_print_invoice was resolved to 1.0.2, which depends on
      deface

    solidus_static_content was resolved to 1.0.0, which depends on
      deface (~> 1.0.2)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

I believe the "culprit" here is the dependency on deface ~> 1.0.2, where hopefully ~> 1.0 would suffice.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "codecov":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      codecov (~> 0.1.16)

Could not find gem 'codecov (~> 0.1.16)', which is required by gem 'solidus_dev_support', in any of the sources.

Bundler could not find compatible versions for gem "rubocop":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop-performance (~> 1.5) was resolved to 1.6.1, which depends on
        rubocop (>= 0.71.0)

    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop-rspec (~> 1.36) was resolved to 1.41.0, which depends on
        rubocop (>= 0.68.1)

    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop (~> 0.76.0)

Bundler could not find compatible versions for gem "solidus_core":
  In Gemfile:
    solidus was resolved to 2.11.0.alpha, which depends on
      solidus_core (= 2.11.0.alpha)

    solidus_auth_devise was resolved to 2.4.0, which depends on
      solidus_core (>= 2.6, < 3)

    solidus_static_content was resolved to 0.0.1, which depends on
      solidus_core (>= 2.0.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "solidus_core":
  In Gemfile:
    solidus was resolved to 3.1.0.alpha, which depends on
      solidus_core (= 3.1.0.alpha)

    solidus_static_content was resolved to 0.0.1, which depends on
      solidus_core (>= 2.0.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Couldn't find Spree::Page

Installed, ran migrations, created a page in the back end, but when trying to visit the slug I get...

ActiveRecord::RecordNotFound in Spree::StaticContentController#show

Couldn't find Spree::Page

def find_by!(*args) # :nodoc:
    find_by(*args) || raise(RecordNotFound.new("Couldn't find #{name}", name))
end

def initialize_generated_modules # :nodoc:

Edit: Just noticed it seems to be unchecking my store check box on every save.

undefined method `glob'

Hi,

I did the instalation of the gem, but when I run

bundle exec rails generate solidus_static_content:install

I get the error:

/bundler/gems/solidus_static_content-8fea401c2818/lib/spree_static_content/engine.rb:22:in activate_overrides: undefined method glob for #<Pathname:0x00000000096fa028> (NoMethodError)

someone already got this error before?

Thanks!

wrong translation key

The english locale lists the wrong key (back_to_static_pages_list):

rgrep back_to
lib/views/backend/spree/admin/pages/new.html.erb:    <%= button_to t("spree.back_to_static_pages_list"), spree.admin_pages_path %>
lib/views/backend/spree/admin/pages/edit.html.erb:    <%= button_to t("spree.back_to_static_pages_list"), spree.admin_pages_path %>

https://github.com/solidusio-contrib/solidus_static_content/tree/master/lib/views/backend/spree/admin/pages
instead defines back_to_pages.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "codecov":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      codecov (~> 0.1.16)

Could not find gem 'codecov (~> 0.1.16)', which is required by gem 'solidus_dev_support', in any of the sources.

Bundler could not find compatible versions for gem "rubocop":
  In Gemfile:
    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop-rspec (~> 1.36) was resolved to 1.41.0, which depends on
        rubocop (>= 0.68.1)

    solidus_dev_support was resolved to 1.5.0, which depends on
      rubocop (~> 0.76.0)

Bundler could not find compatible versions for gem "solidus_core":
  In Gemfile:
    solidus was resolved to 2.11.0.alpha, which depends on
      solidus_core (= 2.11.0.alpha)

    solidus_auth_devise was resolved to 2.4.0, which depends on
      solidus_core (>= 2.6, < 3)

    solidus_static_content was resolved to 0.0.1, which depends on
      solidus_core (>= 2.0.0, < 3)

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Spree::PagesHelper doesn't have `render_snippet` method

While using this extension on Solidus 2.8.2, I get a NoMethod error if I call render_snippet from any view . Looks like the helper is not being loaded automatically.

I had to define render_snippet myself using a decorator to fix the issue.

Any idea why? Has someone encountered the same issue before?

Not compatible with Ruby 3.1.2

When I had the gem in my Gemfile there is an error :

Bundler found conflicting requirements for the Ruby version:
In Gemfile:
solidus_static_content was resolved to 2.0.0, which depends on
Ruby (~> 2.5)

Current Ruby version:
Ruby (= 3.1.2)

Bundler could not find compatible versions for gem "solidus_backend":
In Gemfile:
solidus_backend (~> 3.3)
solidus_static_content was resolved to 1.0.0, which depends on
solidus (< 3, >= 1.1) was resolved to 1.2.0.beta1, which depends on
solidus_backend (= 1.2.0.beta1)

Add html code in static_content

There are some way to add html code in the static page content editor, I have tried all options available in the editor as 'code' , but print it literally.

This is code that I put in the editor:

        <section class="no-padding wow fadeIn">
            <div class="container-fuild">
                <div class="row lightbox-gallery no-margin">
                    <!-- lightbox image #1 -->
                    <div class="col-md-3 col-sm-6 no-padding wow fadeIn" data-wow-duration="300ms"><a href="http://placehold.it/800x600" title=""><img src="http://placehold.it/800x600" alt=""></a></div>
                    <!-- end lightbox image #1 -->
                    <!-- lightbox image #2 -->
                    <div class="col-md-3 col-sm-6 no-padding wow fadeIn" data-wow-duration="600ms"><a href="http://placehold.it/800x600" title=""><img src="http://placehold.it/800x600" alt=""></a></div>
                    <!-- end lightbox image #2 -->
                    <!-- lightbox image #3 -->
                    <div class="col-md-3 col-sm-6 no-padding wow fadeIn" data-wow-duration="900ms"><a href="http://placehold.it/800x600" title=""><img src="http://placehold.it/800x600" alt=""></a></div>
                    <!-- end lightbox image #3 -->
                    <!-- lightbox image #4 -->
                    <div class="col-md-3 col-sm-6 no-padding wow fadeIn" data-wow-duration="300ms"><a href="http://placehold.it/800x600" title=""><img src="http://placehold.it/800x600" alt=""></a></div>
                    <!-- end lightbox image #4 -->
                </div>
            </div>
        </section>

Could not find table 'spree_pages'

Hello am trying to install thins gem went through as intructed that is
added this gem:
gem 'solidus_static_content', github: 'solidusio-contrib/solidus_static_content'
and ran :
bundle exec rails g solidus_static_content:install
but after restarting my server i got an error

Could not find table 'spree_pages'

can i get any help here please?
am using ruby 2.5.1
rails 5.2.0 and with solidus
here is the screenshot

Screenshot_2019-06-29 Action Controller Exception caught

DB Migration not working

bundle exec rails g solidus_static_content:install should copy migration files, but it's not working for my project. (Rails 5.0, Solidus 2.0)

After I run bundle exec rails railties:install:migrations, all migration files are copied and with bundle exec rails db:migrate I'm able to use the static pages.

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.