bigcartel / dugway

Easily build and test Big Cartel themes.
https://developers.bigcartel.com/api/themes
MIT License
149 stars 22 forks source link

Preview local custom HTML pages #90

Open randomgs opened 11 years ago

randomgs commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

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

kukac7 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@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 commented 9 years ago

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 commented 9 years ago

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

kukac7 commented 9 years ago

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

amberfeinerman commented 9 years ago

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 commented 9 years ago

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.