Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview local custom HTML pages #90

Open
randomgs opened this issue Sep 2, 2013 · 18 comments
Open

Preview local custom HTML pages #90

randomgs opened this issue Sep 2, 2013 · 18 comments

Comments

@randomgs
Copy link

randomgs commented Sep 2, 2013

If I want to preview a new custom page — let’s say resellers.html from the source directory— 127.0.0.1:9292/resellers throws a Not Found error. Is there a way — or is it possible — to preview local custom html pages using Dugway server?

@mattwigham
Copy link
Contributor

Hi there. Dugway takes all of its data from live Big Cartel stores, so to preview your reseller page you'd need to add it to a real store on bigcartel.com and then point your theme's config.ru subdomain to it.

This is a clever idea though, so I'll mark this as a feature request for consideration.

@randomgs
Copy link
Author

randomgs commented Sep 4, 2013

Hi and thanks for your answer. It was my first guess but my store is now on maintenance mode. When the dugway server tries to fetch data from a live store in maintenance mode, the terminal throws a bunch of errors, and it makes sense to forbid access to closed stores data. A workaround would be to allow access with a login and a password in the theme’s config.ru. Should I open a specific issue with the thrown errors?

@mattwigham
Copy link
Contributor

Yeah, Dugway uses the Big Cartel read-only API which doesn't provide data on accounts in maintenance mode. I think it'd be a good additional feature request if you'd like to write up a new issue, but it would impact a few things. Namely storing sensitive info in config.ru and committing that to version control, but that can all be worked around.

@pjv
Copy link

pjv commented Feb 24, 2014

Can I back up to the original issue/question? I created an "about" page on my bigcartel site and created an about.html document in my source directory. when i access localhost:9292/about i get a page rendered with my local dugway defined layout, but it does not pull in the page content from about.html. I am not a rails/ruby hacker so I am not immediately oriented where to look in dugway, but if it renders page content for, say, /home.html wouldn't there be a relatively easy hack in there somewhere to be able to add arbitrary custom pages and have it render them too by just copy/pasting the code that handles home.html and just changing the name of the file for the content and the url to render?

Can someone point me where in the source code to look for that?

@outerim
Copy link
Member

outerim commented Feb 24, 2014

@pjv Can you clarify exactly what you expect the behavior to be? Dugway (and the Big Cartel platform in general) understand a limited subset of pages. Anything beyond the default set is considered a custom page and the content for those pages is pulled from the store which you configure dugway to point at. It seems you're trying to have custom pages loaded from the filesystem which is not something dugway currently supports. If that's the case perhaps you could write that up as a separate issue and we can discuss the merits/goals of such an idea in there.

@pjv
Copy link

pjv commented Feb 24, 2014

I guess I wasn't clear with my comment. I understand that what I am asking about (and what I believe that the OP was asking about) is not functionality that dugway currently provides. I want to change that. Since I am a django/python guy and not a rails/ruby guy and don't have an orientation on where to look to start hacking on dugway, to save me reading through all the source code, I was hoping that someone familiar with how the app is structured could point me to the file or files that I would have to change to make dugway be able to render custom pages the same way it renders its pre-defined default pages.

In my reality, if I have to paste code into the bigcartel site to see it rendered every time I make changes to it while I am in development, it sort of renders dugway useless, right?

@outerim
Copy link
Member

outerim commented Feb 25, 2014

@pjv Thanks that's more clear. I've refreshed myself on the code and without actually attempting it I think adding this functionality would be reasonably straightforward. The place you're likely looking to add functionality would be in the Store class. Say around here https://github.com/bigcartel/dugway/blob/master/lib/dugway/store.rb#L32

Essentially I think you'll want to have that pull in pages that exist in the filesystem (say all pages in a custom_pages subdirectory?). The trouble you may run into however is that these pages are assumed to be static per dugway run and the Store class memoizes the pages into a variable. You would need some additional cleverness to make it actually update your pages without resetting the dugway server each time.

@pjv
Copy link

pjv commented Mar 10, 2014

Thanks a lot @outerim, that was exactly what I needed. All I had to do was add the following line into the def theme_pages declaration in the file you pointed me to and dugway started rendering my local about.html page the same as all the builtin default pages.

{ 'name' => 'About', 'permalink' => 'about', 'url' => '/about', 'category' => 'theme' }

perfect. Thanks!

@outerim
Copy link
Member

outerim commented Mar 10, 2014

I'm glad it worked out. I'm going to leave this open since dugway should support a more general solution.

@kukac7
Copy link

kukac7 commented Nov 23, 2014

Similar to my problem.
There is a FAQ page that I have created in the admin interface.
I would like to edit the dugway.
When I start a dugway server, it works in the browser, but I can not edit the layout.
I did a source/faq.html file into anything I wrote, but not displayed.

I tried to see if the file layout.html I write this:

{% if page.full_path contains '/faq' %}
  insert your code here
{% endif %}

It works, but this can only be a single file can be included?

How do I create a custom page layouts unique with dugway?

Thank you for your help!

@amberfeinerman
Copy link

I am also having a similar issue. I would like to create a custom about page layout for my theme. Where can I add the path that was referenced above? The store.rb file?

Thank you!

@pjv
Copy link

pjv commented Nov 24, 2014

yes, i was able to get this working by hacking the store.rb file. below is the def theme_pages function in my store.rb file. note that the last several lines in the function are my own custom pages.

def theme_pages
  [
    { 'name' => 'Home', 'permalink' => 'home', 'url' => '/', 'category' => 'theme' },
    { 'name' => 'Products', 'permalink' => 'products', 'url' => '/products', 'category' => 'theme' },
    { 'name' => 'Product', 'permalink' => 'product', 'url' => '/product', 'category' => 'theme' },
    { 'name' => 'Cart', 'permalink' => 'cart', 'url' => '/cart', 'category' => 'theme' },
    { 'name' => 'Checkout', 'permalink' => 'checkout', 'url' => '/checkout', 'category' => 'theme' },
    { 'name' => 'Success', 'permalink' => 'success', 'url' => '/success', 'category' => 'theme' },
    { 'name' => 'Contact', 'permalink' => 'contact', 'url' => '/contact', 'category' => 'theme' },
    { 'name' => 'About', 'permalink' => 'about', 'url' => '/about', 'category' => 'theme' },
    { 'name' => 'Shipping', 'permalink' => 'shipping', 'url' => '/shipping', 'category' => 'theme' },
    { 'name' => 'Impressum', 'permalink' => 'impressum', 'url' => '/impressum', 'category' => 'theme' },
    { 'name' => 'Maintenance', 'permalink' => 'maintenance', 'url' => '/maintenance', 'category' => 'theme' }
  ]
end

one caveat is that it has been some time since i set this up and i don't know how dugway may have changed in the interim, so YMMV.

@amberfeinerman
Copy link

@pjv Thank you for your help! But I downloaded Dugway from the terminal following the video and I cannot find the store.rb file. Am I totally missing something?

Thank you for your help!

@pjv
Copy link

pjv commented Nov 24, 2014

you might be missing something about how rubygem based projects like dugway work. i'm not a ruby expert by any stretch, but when you are using dugway, all of its source code is stored on your system somewhere as a rubygem. that will be different for different systems depending on how your system has ruby set up. you need to find the gem and then you will find store.rb.

@amberfeinerman
Copy link

Awesome! Thank you for all of your help @pjv ! This was very helpful.

@kukac7
Copy link

kukac7 commented Nov 25, 2014

@pjv I can not find the store.rb file. :( (mac os x 10.7.5)

@amberfeinerman
Copy link

I've found the store.rb file, made the edits, and now I'm trying to implement them, but it seems as if dugway is calling the old version. I'm new-ish to Ruby so I could really use some help. Thank you!

@pjv
Copy link

pjv commented Dec 3, 2014

i had to create the same custom pages (same name) in my big cartel store in order to get it working. so if i added a page called "blat" to store.rb, i added a custom page in bigcartel called "blat".

other than that, if dugway really is seeing a different store.rb than the one you edited, i can't help you. how the ruby environment is set up on your computer is specific to how you set it up. you may have to learn about how ruby environments are managed and how yours in particular is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants