From judofyr at gmail.com Sun Oct 2 07:19:19 2011 From: judofyr at gmail.com (Magnus Holm) Date: Sun, 2 Oct 2011 13:19:19 +0200 Subject: Feature: Simple controllers? In-Reply-To: References: Message-ID: 2011/9/24 Bartosz Dziewo?ski : > So, are we reverting it? It's still in the latest GitHub commit. I've reverted it. From judofyr at gmail.com Sun Oct 2 07:28:09 2011 From: judofyr at gmail.com (Magnus Holm) Date: Sun, 2 Oct 2011 13:28:09 +0200 Subject: Feature: Inline templates? In-Reply-To: References: <3C88508E-3824-4841-B5C2-AA7051F8FA0B@innotts.co.uk> <4E58FBA6.2070706@monnet-usa.com> Message-ID: 2011/9/24 Bartosz Dziewo?ski : > A comment after some time: I'd appreciate it more if I could just have > one "external" file with all the templates, and one with the Camping > code, and I could "link in" the templates to parse using this > mechanism. This works, although it's kinda hacky: eval('Camping.goes :Foo', nil, 'templates.rb') On Fri, Aug 26, 2011 at 16:14, Dave Everitt wrote: > Since no-one has replied, for what it's worth (as a very amateur camper), > I've always been happy with simple regular Markaby views and the v2.1 > options for external templates. Also, my modest one-file apps have their CSS > after __END__. In any sizeable app, you'd probably want to have separate > templates for easier maintenance (since - if inline - their code is going to > add more than a few lines and break the one-file advantages), so the > question is: will anyone use/want inline templates? - DaveE I've committed another patch (8b6fee67). Now you can serve static "files" too: __END__ @@ /style.css * { margin: 0; padding: 0; } It also sets the correct MIME type. The only thing I worry about now is that it's taken a lot of bytes. We're currently at 3976 (97%) bytes. From judofyr at gmail.com Sun Oct 2 07:43:08 2011 From: judofyr at gmail.com (Magnus Holm) Date: Sun, 2 Oct 2011 13:43:08 +0200 Subject: Maintenance release of 2.1 Message-ID: I'm thinking of releasing 2.1.458 which includes a few more features (better cookie support, inline templates etc), but mainly to fix some incompatibility issues with Rack. I'm not going to document the new features yet, so consider them experimental in this patch-release. As for the version, it's currently MAJOR.MINOR.REV where REV = number of commits since the beginning. It works pretty well to use REV as a part of the version number because I can then easily throw out experimental releases to my gem server without screwing up the version number. However, from 2.2 I'm thinking of changing REV to "number of commits since previous release", simply to avoid some high revision numbers. Thoughts? Okay with a little maintenance release? Okay with some undocumented experimental features? Okay with REV? Okay with decreasing REV a bit= // Magnus Holm From a at creativepony.com Sun Oct 2 08:26:47 2011 From: a at creativepony.com (Jenna Fox) Date: Sun, 2 Oct 2011 23:26:47 +1100 Subject: Maintenance release of 2.1 In-Reply-To: References: Message-ID: <-4442413159577078334@unknownmsgid> I wouldn't bother with reducing the revision number. If anything having weirdly high ones makes the project seem more alive and active. Is the minor number even functionally useful here? Maybe we should ditch that and just keep major as a "look! An increment! Heaps cool stuff must have happened!" unless google chrome has ruined new major numbers for everyone anyway. ? Jenna On 02/10/2011, at 10:43 PM, Magnus Holm wrote: > I'm thinking of releasing 2.1.458 which includes a few more features > (better cookie support, inline templates etc), but mainly to fix some > incompatibility issues with Rack. I'm not going to document the new > features yet, so consider them experimental in this patch-release. > > As for the version, it's currently MAJOR.MINOR.REV where REV = number > of commits since the beginning. It works pretty well to use REV as a > part of the version number because I can then easily throw out > experimental releases to my gem server without screwing up the version > number. However, from 2.2 I'm thinking of changing REV to "number of > commits since previous release", simply to avoid some high revision > numbers. > > Thoughts? Okay with a little maintenance release? Okay with some > undocumented experimental features? Okay with REV? Okay with > decreasing REV a bit= > > // Magnus Holm > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list From paul at luon.net Sun Oct 2 15:06:59 2011 From: paul at luon.net (Paul van Tilburg) Date: Sun, 2 Oct 2011 21:06:59 +0200 Subject: failing test In-Reply-To: References: <20110924202203.GA18920@density.luon.net> Message-ID: <20111002190658.GA2753@density.luon.net> On Sat, Sep 24, 2011 at 11:01:42PM +0200, Magnus Holm wrote: > Pretty sure this is related to incompatability with the latest Rack > (which suddenly slightly "broke" the Session-API). It's fixed in > latest master. Maybe we should just do a release soon. Alright. I will follow with packaging once that is out. I already suspected the interplay with Rack. Cheers! Paul -- PhD Student @ Eindhoven | email: paul at luon.net University of Technology, The Netherlands | JID: paul at luon.net >>> Using the Power of Debian GNU/Linux <<< | GnuPG key ID: 0x50064181 From judofyr at gmail.com Mon Oct 3 05:47:14 2011 From: judofyr at gmail.com (Magnus Holm) Date: Mon, 3 Oct 2011 11:47:14 +0200 Subject: Maintenance release of 2.1 In-Reply-To: <-4442413159577078334@unknownmsgid> References: <-4442413159577078334@unknownmsgid> Message-ID: On Sun, Oct 2, 2011 at 14:26, Jenna Fox wrote: > I wouldn't bother with reducing the revision number. If anything > having weirdly high ones makes the project seem more alive and active. > Is the minor number even functionally useful here? Maybe we should > ditch that and just keep major as a "look! An increment! Heaps cool > stuff must have happened!" unless google chrome has ruined new major > numbers for everyone anyway. Well, it's useful for computability reasons. Every app created on 2.x should work on 2.x+n with minimal required changes. From a at creativepony.com Mon Oct 3 06:29:58 2011 From: a at creativepony.com (Jenna Fox) Date: Mon, 3 Oct 2011 21:29:58 +1100 Subject: Maintenance release of 2.1 In-Reply-To: References: <-4442413159577078334@unknownmsgid> Message-ID: <0D36DEBD-A3C8-4BC8-920E-A76679B0D849@creativepony.com> True that. Meanwhile, have you guys seen ? It looks pretty nice, and I imagine something like that could be pretty powerful if deeply integrated with a version of markaby, as a 'ui toolkit for the web' sort of thing - a nice sensible clean default style for quickly prototyping ideas, and teaching beginners the concepts of the web. ? Jenna On 03/10/2011, at 8:47 PM, Magnus Holm wrote: > On Sun, Oct 2, 2011 at 14:26, Jenna Fox wrote: >> I wouldn't bother with reducing the revision number. If anything >> having weirdly high ones makes the project seem more alive and active. >> Is the minor number even functionally useful here? Maybe we should >> ditch that and just keep major as a "look! An increment! Heaps cool >> stuff must have happened!" unless google chrome has ruined new major >> numbers for everyone anyway. > > Well, it's useful for computability reasons. Every app created on 2.x > should work on 2.x+n with minimal required changes. > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From matma.rex at gmail.com Mon Oct 3 11:31:45 2011 From: matma.rex at gmail.com (=?UTF-8?Q?Bartosz_Dziewo=C5=84ski?=) Date: Mon, 3 Oct 2011 17:31:45 +0200 Subject: Maintenance release of 2.1 In-Reply-To: <0D36DEBD-A3C8-4BC8-920E-A76679B0D849@creativepony.com> References: <-4442413159577078334@unknownmsgid> <0D36DEBD-A3C8-4BC8-920E-A76679B0D849@creativepony.com> Message-ID: Personally I hate it. It's like and once again, except this time camouflaged as CSS classes. The only good things in there are either styled pretty much the same way by default (like, say, headers), or require a line of code (@basefont, layouts). -- Matma Rex 2011/10/3 Jenna Fox : > Meanwhile, have you guys seen ? It > looks pretty nice, and I imagine something like that could be pretty > powerful if deeply integrated with a version of markaby, as a 'ui toolkit > for the web' sort of thing - a nice sensible clean default style for quickly > prototyping ideas, and teaching beginners the concepts of the web. > From a at creativepony.com Mon Oct 3 18:41:28 2011 From: a at creativepony.com (Jenna Fox) Date: Tue, 4 Oct 2011 09:41:28 +1100 Subject: Maintenance release of 2.1 In-Reply-To: References: <-4442413159577078334@unknownmsgid> <0D36DEBD-A3C8-4BC8-920E-A76679B0D849@creativepony.com> Message-ID: <3391269133871140332@unknownmsgid> Oh right, but you can use that LESS thing I think to compile the bootstrap properties in to your regular CSS, so you keep using good quality selectors, and bootstrap essentially augments your CSS with useful macros. Another way to do it is to define markaby helpers for each kind of thing, so you can still just go change one small piece of code to restyle the whole site's whizlebobs. ? Jenna On 04/10/2011, at 3:07 AM, "Bartosz Dziewo?ski" wrote: > Personally I hate it. It's like
and > once again, except this time camouflaged as CSS classes. The only good > things in there are either styled pretty much the same way by default > (like, say, headers), or require a line of code (@basefont, layouts). > > -- Matma Rex > > > > 2011/10/3 Jenna Fox : >> Meanwhile, have you guys seen ? It >> looks pretty nice, and I imagine something like that could be pretty >> powerful if deeply integrated with a version of markaby, as a 'ui toolkit >> for the web' sort of thing - a nice sensible clean default style for quickly >> prototyping ideas, and teaching beginners the concepts of the web. >> > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list From a at creativepony.com Tue Oct 4 20:20:31 2011 From: a at creativepony.com (Jenna Fox) Date: Wed, 5 Oct 2011 11:20:31 +1100 Subject: Simplest easiest rss feeds? Message-ID: I'm looking to make rss feeds of some of my controller data - what's the simplest way to render some? Is there some way I can feed a json-like arrays of hashes type of structure in to some gem and get out an xml feed? Would it be more of a builder sort of operation? ? Jenna -------------- next part -------------- An HTML attachment was scrubbed... URL: From a at creativepony.com Tue Oct 4 21:34:18 2011 From: a at creativepony.com (Jenna Fox) Date: Wed, 5 Oct 2011 12:34:18 +1100 Subject: Helpers and R() routes Message-ID: <666E0083-8DEA-4AE6-8356-9F918626E590@creativepony.com> It'd be cool if in the next version of camping, you could use R(ControllerName, *args) inside of helper methods, rather than having to go all out with R(MyApp::Controllers::ControllerName, *args) ? Jenna -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at steveklabnik.com Tue Oct 4 21:48:52 2011 From: steve at steveklabnik.com (Steve Klabnik) Date: Tue, 4 Oct 2011 21:48:52 -0400 Subject: Simplest easiest rss feeds? In-Reply-To: References: Message-ID: There's an RSS generator in the standard library. From a at creativepony.com Tue Oct 4 23:06:51 2011 From: a at creativepony.com (Jenna Fox) Date: Wed, 5 Oct 2011 14:06:51 +1100 Subject: Simplest easiest rss feeds? In-Reply-To: References: Message-ID: So there is! Thanks Steve! ? Jenna On 05/10/2011, at 12:48 PM, Steve Klabnik wrote: > There's an RSS generator in the standard library. > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Wed Oct 5 03:19:54 2011 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 5 Oct 2011 09:19:54 +0200 Subject: Simplest easiest rss feeds? In-Reply-To: References: Message-ID: On Wed, Oct 5, 2011 at 02:20, Jenna Fox wrote: > I'm looking to make rss feeds of some of my controller data - what's the > simplest way to render some? Is there some way I can feed a json-like arrays > of hashes type of structure in to some gem and get out an xml feed? Would it > be more of a builder sort of operation? > > ? > Jenna I haven't tried the RSS generator, so I don't know how well it works, but I've been doing this: https://github.com/judofyr/timeless/blob/master/timeless/views/feed.erb From lists at groll.co.za Wed Oct 5 03:32:50 2011 From: lists at groll.co.za (Jonathan Groll) Date: Wed, 05 Oct 2011 09:32:50 +0200 Subject: Simplest easiest rss feeds? In-Reply-To: References: Message-ID: <874nzn6ggt.wl%lists@groll.co.za> On Wed, 5 Oct 2011 11:20:31 +1100, Jenna Fox wrote: > [1 ] > [1.1 ] > > [1.2 ] > I'm looking to make rss feeds of some of my controller data - what's the > simplest way to render some? Is there some way I can feed a json-like arrays > of hashes type of structure in to some gem and get out an xml feed? Would it > be more of a builder sort of operation? An example. Succinct. RSS:Maker. For your reference. (from my blogging engine written with Camping 1.9): Firstly, need to require rss/maker, then module Blogg::Controllers class Index < R '/', '/tag/([-\w]+)', '/(rss)', '/(rss)/([-\w]+)' def get ( format='html', *rest ) ... then later on: # Produce RSS feed if format == 'rss' content = RSS::Maker.make('2.0') do |m| m.channel.title = @@config[:title] m.channel.about = URL().to_s + '/rss' m.channel.link = URL().to_s m.channel.description = @@config[:descr] m.items.do_sort = true # sort items by date for post in @posts if post.okayed == true && tag_matches?(post, @tagg) i = m.items.new_item i.title = post.title i.link = URL(View, post.slug).to_s i.guid.content = URL(View, post.id).to_s i.guid.isPermaLink = true ar = post.body.split(/^---!/) i.description = RedCloth.new(ar[1]).to_html i.description << RedCloth.new(ar[2]).to_html if (ar[2] != nil && ar[2] != "\r\n" && ar[2] != "") i.date = post.when end end end r 200, content.to_s, 'Content-Type' => 'application/rss+xml; charset=UTF-8' Notes: I use ---! to mark a block at the beginning of a post - this block is the description of the post. Redcloth markdown is used. Cheers, Jonathan -- jjg: Jonathan J. Groll : groll co za has_one { :blog => "http://bloggroll.com" } Sent from my computer device which runs on free software From judofyr at gmail.com Wed Oct 5 03:40:38 2011 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 5 Oct 2011 09:40:38 +0200 Subject: Helpers and R() routes In-Reply-To: <666E0083-8DEA-4AE6-8356-9F918626E590@creativepony.com> References: <666E0083-8DEA-4AE6-8356-9F918626E590@creativepony.com> Message-ID: I've added a failing test: https://github.com/camping/camping/commit/7aa0e1fa934806f964ad120c1b4bb21783c7e008 Will look into it later :-) // Magnus Holm On Wed, Oct 5, 2011 at 03:34, Jenna Fox wrote: > It'd be cool if in the next version of camping, you could use > R(ControllerName, *args) inside of helper methods, rather than having to go > all out with R(MyApp::Controllers::ControllerName, *args) > ? > Jenna > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From matma.rex at gmail.com Wed Oct 5 12:48:31 2011 From: matma.rex at gmail.com (=?UTF-8?Q?Bartosz_Dziewo=C5=84ski?=) Date: Wed, 5 Oct 2011 18:48:31 +0200 Subject: Simplest easiest rss feeds? In-Reply-To: <874nzn6ggt.wl%lists@groll.co.za> References: <874nzn6ggt.wl%lists@groll.co.za> Message-ID: I was only once generating an RSS feed, and I just did it with Markaby. You can see live example here: http://warlightrss.heroku.com/general - and the source code: (RSS generation is at the very bottom) http://warlightrss.heroku.com/source/web.rb Also, don't judge, this is old (still just works, so I didn't mess with it for some time). ;) -- Matma Rex From a at creativepony.com Wed Oct 5 20:05:52 2011 From: a at creativepony.com (Jenna Fox) Date: Thu, 6 Oct 2011 11:05:52 +1100 Subject: Simplest easiest rss feeds? In-Reply-To: References: <874nzn6ggt.wl%lists@groll.co.za> Message-ID: That's cool! :D ? Jenna On 06/10/2011, at 3:48 AM, Bartosz Dziewo?ski wrote: > I was only once generating an RSS feed, and I just did it with > Markaby. You can see live example here: > http://warlightrss.heroku.com/general - and the source code: (RSS > generation is at the very bottom) > http://warlightrss.heroku.com/source/web.rb > > Also, don't judge, this is old (still just works, so I didn't mess > with it for some time). ;) > > -- Matma Rex > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From deveritt at innotts.co.uk Fri Oct 7 09:30:15 2011 From: deveritt at innotts.co.uk (Dave Everitt) Date: Fri, 7 Oct 2011 14:30:15 +0100 Subject: A question about the ecosystem. In-Reply-To: References: <925E1D6B-EF49-497E-B9B5-2D8CFB92C215@creativepony.com> Message-ID: > > I stuck my openid code up here: http://creativepony.com/archive/journal/scripts/camping-openid-consumer/ > - you'll also need the openid rubygem Jenna - thanks for that. It might just be exactly what I need... - DaveE -------------- next part -------------- An HTML attachment was scrubbed... URL: From deveritt at innotts.co.uk Fri Oct 7 09:24:55 2011 From: deveritt at innotts.co.uk (Dave Everitt) Date: Fri, 7 Oct 2011 14:24:55 +0100 Subject: Feature: Inline templates? In-Reply-To: References: <3C88508E-3824-4841-B5C2-AA7051F8FA0B@innotts.co.uk> <4E58FBA6.2070706@monnet-usa.com> Message-ID: > On Fri, Aug 26, 2011 at 16:14, Dave Everitt > wrote: >> Since no-one has replied, for what it's worth (as a very amateur >> camper), >> I've always been happy with simple regular Markaby views and the v2.1 >> options for external templates. Also, my modest one-file apps have >> their CSS >> after __END__. In any sizeable app, you'd probably want to have >> separate >> templates for easier maintenance (since - if inline - their code is >> going to >> add more than a few lines and break the one-file advantages), so the >> question is: will anyone use/want inline templates? - DaveE > > I've committed another patch (8b6fee67). Now you can serve static > "files" too: > > __END__ > @@ /style.css > * { margin: 0; padding: 0; } > > It also sets the correct MIME type. > > The only thing I worry about now is that it's taken a lot of bytes. > We're currently at 3976 (97%) bytes. So further feature-creep is to be avoided. I'm also happy calling stylesheets within Markaby: head do title 'My Blog' link :rel => 'stylesheet', :type => 'text/css', :href => '/styles.css', :media => 'screen' end DaveE From deveritt at innotts.co.uk Sat Oct 8 08:53:01 2011 From: deveritt at innotts.co.uk (Dave Everitt) Date: Sat, 8 Oct 2011 13:53:01 +0100 Subject: Advice on strategy for maintaining state in Camping In-Reply-To: References: Message-ID: Anders - if you get this working, do let us know (with any relevant links). It'd be good to show the world... I worked for some time on disability/technology/art projects, and I know at least one large UK network of users that would be interested - DaveE > Hi, > > I need a little advice about maintaining state in Camping. > > I use NaturallySpeaking voice recognition software for most of my > work -- I don't have happy hands -- and I've been creating little > Ruby projects to make it easier to do some things by voice. I'd like > to build a UI for them. After some painful experiences with some > windows-based UIs, I'd like to try using Camping ? it looks like > fun, and I can use my HTML/CSS skills to make something pretty. > > For most of these little Ruby projects, I don't have to store > anything in a database because the data is already being stored > elsewhere. For example, I'm managing a team that's building a > Microsoft-based data warehouse that uses Excel pivot tables as a > front-end, and pivot tables are hard to manipulate using > NaturallySpeaking. On my Camping site, I want to be able to display > a long list of the available pivot table fields so I can click on > them by voice. I also want a text box so I can say, e.g., "show > department and unit by row, year by column" or "only show fields > containing committee." So all I need to store is the info I'm using > to manipulate the pivot table: the connection to the Excel > worksheet and a list of the available fields that I grab from the > Excel worksheet plus one or two properties about these fields. I > don't need to save any of this info -- I grab it once at the > beginning of the session, and I don't want to cache it because, for > example, the list of fields will change depending on which data > warehouse "cube" I'm connecting to. I have other projects where the > data is stored on a website/application that I'm grabbing/ > manipulating using Web services/APIs. In short, I don't need to > permanently store any data, I just need to maintain state for a > relatively small number of objects. > > What's the easiest way to do this in Camping? Is there a way to > cache the list of field objects? Or does it make more sense to store > them in a database and purge & refresh the data in the database each > time I start up the Camping site? > > Thanks! > Anders > > PS Maybe you're thinking, "using Excel pivot tables as a front-end > to a data warehouse??" It does sound bizarre, and I was pretty > skeptical at first, but it actually works pretty well. Microsoft has > put a fair amount of work into turning Excel pivot tables into a > pretty decent data warehouse front end. And since you're just using > Excel, you get all the goodies are built into Excel. Not a good > front-end if you are creating straightforward dashboards that are > totally locked down, but if you have a pretty broad range of fields > and you're encouraging folks to slice and dice the data themselves, > it ends up being easier than most of the other tools out there. > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list From uzleepito at gmail.com Sun Oct 9 09:43:46 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Sun, 9 Oct 2011 15:43:46 +0200 Subject: run my Camping app as a Rack app Message-ID: Hi, Could you please show me the preferred/nicest way to run my Camping application as a Rack all? I like doing my work in Rack because it's easy to run my app in a standalone webserver, or "mount" it to a path in my production environment as a FastCGI app. require 'rubygems' require 'rack' app = ... Rack::Handler::FastCGI.run app, :Port => nnnn I use Camping as a proof-of-concept framework, but it's time to turn some of my apps into production, and I'm looking for the right way to do this, and I think this is to make it run as a Rack app. I've found code snippets on the net but none of them worked. This one is the less wrong one: require 'rubygems' require 'rack' require 'camping' Camping.goes :X module X # my Camping app here # end X.create Rack::Handler::FastCGI.run X, :Port => 8899 I know it's not good. Basicly my question is: how to repair this? :) I have two problems: 1) X.create makes ugly error messages 2) if I comment out the X.create line, it seems to work, but does not really do. It listens for connections on 8899, but it halt on the first fcgi connection from the webserver. thx, uzlee -------------- next part -------------- An HTML attachment was scrubbed... URL: From matma.rex at gmail.com Sun Oct 9 11:21:10 2011 From: matma.rex at gmail.com (=?UTF-8?Q?Bartosz_Dziewo=C5=84ski?=) Date: Sun, 9 Oct 2011 17:21:10 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: I'm not sure what are you trying to accomplish. Can't you just create a config.ru file like this: require './yourapp.rb' run YourApp And then use `rackup` to start the app? config.ru files are widely understood, the same thing works for example with mod_passenger or Heroku. -- Matma Rex From uzleepito at gmail.com Sun Oct 9 13:10:03 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Sun, 9 Oct 2011 19:10:03 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: Yes, You are right, that works in this way. But this is a bit different what I want to do. rackup runs my Rack application in a webserver (webrick or mongrel), and I can't use orher handlers than these. I prefer to use Rack in a bit lower level. Suppose that in a standard Ruby script the object `obj` implements tha Rack interface. In this case I can simply run it in this way: require 'rack' Rack::Handler::WEBrick.run obj or require 'rack' Rack::Handler::Mongrel.run obj without all the magic of rackup. This has the advantage to use other handlers, not only WEBrick and Mongrel. I can user Rack::Handler::Thin, ...::CGI, and even ...::FastCGI. What I really want to do is to run my Camping app using the Rack::Handler::FastCGI. I would like to know how can I convert my Camping app into an object (module, class, lambda or anything else) in Ruby that implements the Rack interface, and I can push it to Rack::Handler::FastCGI.run(). If there is any other way to run a Camping app as a fastcgi, that can be also a good solution. -- uzlee 2011/10/9 Bartosz Dziewo?ski > I'm not sure what are you trying to accomplish. > > Can't you just create a config.ru file like this: > require './yourapp.rb' > run YourApp > > And then use `rackup` to start the app? > > config.ru files are widely understood, the same thing works for > example with mod_passenger or Heroku. > > -- Matma Rex > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matma.rex at gmail.com Sun Oct 9 14:50:29 2011 From: matma.rex at gmail.com (=?UTF-8?Q?Bartosz_Dziewo=C5=84ski?=) Date: Sun, 9 Oct 2011 20:50:29 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: The app itself implements Rack protocol. (That is, if you do Camping.goes :App, then your "obj" variable would be App - it implements .call, I think it's all that's needed?) -- Matma Rex From uzleepito at gmail.com Sun Oct 9 15:24:31 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Sun, 9 Oct 2011 21:24:31 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: > > The app itself implements Rack protocol. > Yes, that's what I've already tried. It is the case when my app stops whenever the first fastcgi request arrives: /usr/lib/ruby/1.8/rack/utils.rb:23:in `unescape': undefined method `tr' for nil:NilClass (NoMethodError) from (eval):33:in `call' from /usr/lib/ruby/1.8/rack/session/cookie.rb:37:in `call' from (eval):38:in `call' from /usr/lib/ruby/1.8/rack/content_length.rb:13:in `call' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:57:in `serve' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:25:in `run' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `each' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `run' ... What I do here is: require 'camping' require 'camping/session' Camping.goes :App module App # ..... here is my Camping App end Rack::Handler::FastCGI.run App, :Port => 9000 ...and configure webserver to send fcgi queries to 9000. Is this a Rack problem? (In this case I'm sorry bothering you!) uzlee -------------- next part -------------- An HTML attachment was scrubbed... URL: From matma.rex at gmail.com Sun Oct 9 16:05:01 2011 From: matma.rex at gmail.com (=?UTF-8?Q?Bartosz_Dziewo=C5=84ski?=) Date: Sun, 9 Oct 2011 22:05:01 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: Does it work the "regular" way? (via rackup) Does it work "your" way, but with a different handler? Which version of rack you're using? I can't find any usage of tr method in 1.3.4's rack/utils.rb, and line 37 of rack/session/cookie.rb is a comment. -- Matma Rex From dsusco at gmail.com Sun Oct 9 17:08:11 2011 From: dsusco at gmail.com (David Susco) Date: Sun, 9 Oct 2011 17:08:11 -0400 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: Are you running Apache? Is so, try installing passenger. I've got half a dozen apps running via this, it makes things pretty easy. http://www.modrails.com/ Dave 2011/10/9 Bartosz Dziewo?ski : > Does it work the "regular" way? (via rackup) > > Does it work "your" way, but with a different handler? > > Which version of rack you're using? I can't find any usage of tr > method in 1.3.4's rack/utils.rb, and line 37 of rack/session/cookie.rb > is a comment. > > -- Matma Rex > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -- Dave From uzleepito at gmail.com Sun Oct 9 17:45:15 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Sun, 9 Oct 2011 23:45:15 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: > Does it work the "regular" way? (via rackup) > Yes, rackup makes my app run. In this case an other probleme occures, that is more Camping specific. The ActiveRecord cannot connect to any database. I think Camping makes some initialization before starting up my app, that is missing in this case. (I've tried to call App.create before the Rack handler, but it's not the right way.) > Does it work "your" way, but with a different handler? > Yes, with (for example) Rack::Handler::WEBrick works the same way as with rackup. I can connect to the app with my browser, but ActiveRecord fails to work. But I use Rack::Handler::FastCGI with other Rack apps, and it works. > Which version of rack you're using? I tried it with ruby1.9.2 with the latest rack gem a few days ago, that was 1.3.4. It did not work, so I downgraded. Now I'm using ruby 1.8 and the standard librack-ruby1.8 package in Ubuntu. It's version is 1.1.0-4ubuntu1. -- uzlee -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Sun Oct 9 17:52:17 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Sun, 9 Oct 2011 23:52:17 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: > Are you running Apache? No, the webserver is nginx, and I use fastcgi to attach my apps into it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From a at creativepony.com Sun Oct 9 20:10:02 2011 From: a at creativepony.com (Jenna Fox) Date: Mon, 10 Oct 2011 11:10:02 +1100 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: <53B68ABE-32AF-40AA-AD9A-A0A0F16F05BF@creativepony.com> It looks as if your application is getting a FastCGI request without the 'PATH_INFO' environment variable. I'm not too sure what to make of that. Can you try a rackup which runs this app? require 'rack' require 'pp' App = lambda do |env| body = '' PP.pp env, body [200, 'Content-Type' => 'text/plain', body] end Rack::Handler::FastCGI.run App, :Port => 9000 and let us know what it prints out as being in the environment. Maybe your webserver doesn't provide PATH_INFO over FastCGI. If that's the case, we'll need to consider how we can be compatible with that. ? Jenna On 10/10/2011, at 6:24 AM, Nokan Emiro wrote: > The app itself implements Rack protocol. > > > Yes, that's what I've already tried. It is the case when my > app stops whenever the first fastcgi request arrives: > > /usr/lib/ruby/1.8/rack/utils.rb:23:in `unescape': undefined method `tr' for nil:NilClass (NoMethodError) > from (eval):33:in `call' > from /usr/lib/ruby/1.8/rack/session/cookie.rb:37:in `call' > from (eval):38:in `call' > from /usr/lib/ruby/1.8/rack/content_length.rb:13:in `call' > from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:57:in `serve' > from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:25:in `run' > from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `each' > from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `run' > ... > > What I do here is: > > require 'camping' > require 'camping/session' > Camping.goes :App > module App > # ..... here is my Camping App > end > Rack::Handler::FastCGI.run App, :Port => 9000 > > ...and configure webserver to send fcgi queries to 9000. > > Is this a Rack problem? (In this case I'm sorry bothering you!) > > uzlee > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Mon Oct 10 01:30:27 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Mon, 10 Oct 2011 07:30:27 +0200 Subject: run my Camping app as a Rack app In-Reply-To: <53B68ABE-32AF-40AA-AD9A-A0A0F16F05BF@creativepony.com> References: <53B68ABE-32AF-40AA-AD9A-A0A0F16F05BF@creativepony.com> Message-ID: > require 'rack' > require 'pp' > > App = lambda do |env| > body = '' > PP.pp env, body > [200, {'Content-Type' => 'text/plain'}, body] > end > > Rack::Handler::FastCGI.run App, :Port => 9000 > {"HTTP_ACCEPT"=> "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "HTTP_HOST"=>"www.mytestsite.com", "SERVER_NAME"=>"mytestsite.com", "REQUEST_PATH"=>"/", "rack.url_scheme"=>"http", "HTTP_KEEP_ALIVE"=>"115", "HTTP_USER_AGENT"=> "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.04 (lucid) Firefox/3.6.23", "DOCUMENT_URI"=>"/", "rack.errors"=>#, "HTTP_ACCEPT_LANGUAGE"=>"hu,en-us;q=0.7,en;q=0.3", "SERVER_PROTOCOL"=>"HTTP/1.1", "FCGI_ROLE"=>"RESPONDER", "rack.version"=>[1, 1], "rack.run_once"=>false, "REMOTE_ADDR"=>"**.***.**.**", "SERVER_SOFTWARE"=>"nginx/1.0.5", "SERVER_ADDR"=>"192.168.100.200", "SCRIPT_NAME"=>"", "HTTP_VERSION"=>"HTTP/1.1", "rack.multithread"=>false, "rack.multiprocess"=>true, "REMOTE_PORT"=>"35088", "REQUEST_URI"=>"/", "HTTP_ACCEPT_CHARSET"=>"ISO-8859-1,utf-8;q=0.7,*;q=0.7", "SERVER_PORT"=>"443", "DOCUMENT_ROOT"=>"/var/www/mytestsite.com", "REQUEST_METHOD"=>"GET", "SCRIPT_FILENAME"=>"/var/www/mytestsite.com/", "rack.input"=> #, @rewindable_io=nil, @unlinked=false>, "HTTP_CONNECTION"=>"keep-alive", "HTTP_ACCEPT_ENCODING"=>"gzip,deflate", "REDIRECT_STATUS"=>"200", "GATEWAY_INTERFACE"=>"CGI/1.1", "QUERY_STRING"=>""} You are right, there is no PATH_INFO. This line in the webserver config file helped the fastcgi problem: fastcgi_param PATH_INFO $fastcgi_path_info; Thanks a lot! uzlee -------------- next part -------------- An HTML attachment was scrubbed... URL: From gravious at jollyrotten.org Mon Oct 10 08:28:33 2011 From: gravious at jollyrotten.org (Anthony Durity) Date: Mon, 10 Oct 2011 15:28:33 +0300 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: Hi all, What I do is check the ENV variable ... and I use Passenger Phusion to run my Rack apps So ... like this ... install Apache and Passenger Phusion and point passenger at a rack_apps dir (under the web server root) Now I have /var/www/localhost/htdocs <- web server doc root /var/www/localhost/htdocs/rack_apps/* <- rack_apps cd /var/www/localhost/htdocs and camping rack_apps/*/config.ru runs all my Camping apps in dev mode or ... to run as a rack app (using passenger) at the end of your config.ruput this addendum Camping.goes :MyApp module MyApp # blah blah blah end case ENV['RACK_ENV'] when 'development' # set a mode var? debug "i'm in rack dev mode" ENV['MODE'] = 'development' when 'production' # set a mode var? debug "i'm in rack live mode" ENV['MODE'] ||= 'production' run MyApp # !!!!!! this is the important bit !!!!! else ENV['MODE'] = nil end if __FILE__ == $0 # this library may be run as a standalone script # as in -> ruby rack_apps/___/config.ru # dunno why you'd want to do that but anyway # set a mode var? debug "i'm in standalone mode" ENV['MODE']='standalone' end I don't know, maybe this is all obvious but it took me a little while to figure it out cuz I'm a bit slow about these things. Regards, Anthony On Sun, Oct 9, 2011 at 4:43 PM, Nokan Emiro wrote: > Hi, > > Could you please show me the preferred/nicest way > to run my Camping application as a Rack all? I like > doing my work in Rack because it's easy to run my app > in a standalone webserver, or "mount" it to a path in > my production environment as a FastCGI app. > > require 'rubygems' > require 'rack' > app = ... > Rack::Handler::FastCGI.run app, :Port => nnnn > > I use Camping as a proof-of-concept framework, but it's > time to turn some of my apps into production, and I'm looking > for the right way to do this, and I think this is to make it run > as a Rack app. I've found code snippets on the net but > none of them worked. This one is the less wrong one: > > require 'rubygems' > require 'rack' > require 'camping' > > Camping.goes :X > module X > # my Camping app here # > end > > X.create > > Rack::Handler::FastCGI.run X, :Port => 8899 > > I know it's not good. Basicly my question is: how to repair this? :) > > I have two problems: > > 1) X.create makes ugly error messages > 2) if I comment out the X.create line, it seems to work, but does > not really do. It listens for connections on 8899, but it halt on > the first fcgi connection from the webserver. > > thx, > uzlee > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Tue Oct 11 03:02:45 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Tue, 11 Oct 2011 09:02:45 +0200 Subject: Camping into production Message-ID: Hi, As you already know I'm working on turning my Camping app into production. Unfortunatelly I find lots of problems on my way. The next one is here: My Camping app does something dirty on the 'redirect CtrllerName' lines. The webserver serves https requests, and before I placed fastcgi_param HTTPS on; which passes these two params to the fastcgi application: "HTTPS"=>"on", "rack.url_scheme"=>"https", But my app fails on the first redirect line in my controllers: (eval):10:in `URL': undefined method `+' for nil:NilClass (NoMethodError) from (eval):15:in `redirect' from /home/bsanyi/MyApp.rb:53:in `post' from (eval):24:in `send' from (eval):24:in `service' from (eval):24:in `catch' from (eval):24:in `service' from (eval):34:in `call' from /usr/lib/ruby/1.8/rack/session/cookie.rb:37:in `call' from (eval):38:in `call' from /usr/lib/ruby/1.8/rack/content_length.rb:13:in `call' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:57:in `serve' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:25:in `run' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `each' from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `run' MyApp.rb:53 is a `redirect ControllerName` line. What do I wrong? Redirects are working with different Rack handlers than FascCGI. And I'm sure it is related to the https, because before I switched HTTPS on in my webserver, redirect worked, but to http (not https) and port 443 - which was of course a wrong combination. Now Rack know about https, and my app seems to work until the first redirect. The same happens in ruby1.8 + ubuntu packages of rack and camping (and other necessary libs), and with ruby1.9.2 and the latest gems. The above error message is from 1.8. uzlee -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Tue Oct 11 03:15:08 2011 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 11 Oct 2011 09:15:08 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: On Tue, Oct 11, 2011 at 09:02, Nokan Emiro wrote: > Hi, > > As you already know I'm working on turning my Camping app > into production.? Unfortunatelly I find lots of problems on my way. > The next one is here: > > My Camping app does something dirty on the 'redirect CtrllerName' > lines.? The webserver serves https requests, and before I placed > > fastcgi_param HTTPS on; > > which passes these two params to the fastcgi application: > > "HTTPS"=>"on", > "rack.url_scheme"=>"https", > > But my app fails on the first redirect line in my controllers: > > (eval):10:in `URL': undefined method `+' for nil:NilClass (NoMethodError) > ??????? from (eval):15:in `redirect' > ??????? from /home/bsanyi/MyApp.rb:53:in `post' > ??????? from (eval):24:in `send' > ??????? from (eval):24:in `service' > ??????? from (eval):24:in `catch' > ??????? from (eval):24:in `service' > ??????? from (eval):34:in `call' > ??????? from /usr/lib/ruby/1.8/rack/session/cookie.rb:37:in `call' > ??????? from (eval):38:in `call' > ??????? from /usr/lib/ruby/1.8/rack/content_length.rb:13:in `call' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:57:in `serve' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:25:in `run' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `each' > ??????? from /usr/lib/ruby/1.8/rack/handler/fastcgi.rb:24:in `run' Could you run `pp @env` inside the controller and paste the result here? (or in a pastie.org) require 'pp' module MyApp::Controllers class InTheControllerThatFails def post pp @env redirect BlaBla end end end From judofyr at gmail.com Tue Oct 11 03:50:26 2011 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 11 Oct 2011 09:50:26 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: On Sun, Oct 9, 2011 at 15:43, Nokan Emiro wrote: > Hi, > > Could you please show me the preferred/nicest way > to run my Camping application as a Rack all?? I like > doing my work in Rack because it's easy to run my app > in a standalone webserver, or "mount" it to a path in > my production environment as a FastCGI app. > > require 'rubygems' > require 'rack' > app = ... > Rack::Handler::FastCGI.run app, :Port => nnnn > > I use Camping as a proof-of-concept framework, but it's > time to turn some of my apps into production, and I'm looking > for the right way to do this, and I think this is to make it run > as a Rack app.? I've found code snippets on the net but > none of them worked.? This one is the less wrong one: > > require 'rubygems' > require 'rack' > require 'camping' > > Camping.goes :X > module X > ??? # my Camping app here # > end > > X.create > > Rack::Handler::FastCGI.run X, :Port => 8899 > > I know it's not good.? Basicly my question is:? how to repair this? :) > > I have two problems: > > 1) X.create makes ugly error messages Now that you have solved your real problem, let me explain this one too: X.create is purely a convention so you can write code that will run on startup inside your application. So you can write this in your application: def X.create # run migrations etc. end Then a "proper" Camping server (like your FastCGI-wrapper) will make sure to invoke X.create. Of course, a proper Camping server must also take care to handle applications that *don't* define X.create, so that line should actually look like this: # inside the server: X.create if X.respond_to? :create From uzleepito at gmail.com Tue Oct 11 12:00:00 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Tue, 11 Oct 2011 18:00:00 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: Sensiteve parts are masked with *******. http://pastie.org/2676396 u. On Tue, Oct 11, 2011 at 9:15 AM, Magnus Holm wrote: > Could you run `pp @env` inside the controller and paste the result > here? (or in a pastie.org) > > require 'pp' > > module MyApp::Controllers > class InTheControllerThatFails > def post > pp @env > redirect BlaBla > end > end > end > -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Tue Oct 11 12:21:35 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Tue, 11 Oct 2011 18:21:35 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: Thanks for the explanation. I have had the create method in my application, it calls Models::create_scheme, because I have migrations too. (Everything encapsulated, that's what I like about Camping.) Actually the problem with X.create was that my fastcgi-camping-server did not initialize any ActiveRecord connections, while the standard camping server did. After I placed this ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "localhost", :user => "*****", :password => "******", :database => "databasename" ) before the X.create line, it worked fine. Anyway that generated a question. As you can see I replaced sqlite to mysql, and now I can see in the mysql database, that table names are in form of databasename_tablename, and I have an extra databasename_schema_infos table too. How can I turn this behavior off? It's not critical, but a bit ugly. uzlee On Tue, Oct 11, 2011 at 9:50 AM, Magnus Holm wrote: > Now that you have solved your real problem, let me explain this one too: > > X.create is purely a convention so you can write code that will run on > startup inside your application. So you can write this in your > application: > > def X.create > # run migrations etc. > end > > Then a "proper" Camping server (like your FastCGI-wrapper) will make > sure to invoke X.create. Of course, a proper Camping server must also > take care to handle applications that *don't* define X.create, so that > line should actually look like this: > > # inside the server: > X.create if X.respond_to? :create > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Tue Oct 11 13:46:12 2011 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 11 Oct 2011 19:46:12 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: On Tue, Oct 11, 2011 at 18:00, Nokan Emiro wrote: > Sensiteve parts are masked with *******. > > http://pastie.org/2676396 > > u. Thanks. This is a bug in Camping which has been fixed in 5423c7a0. You can install the latest development version of Camping by running: gem install camping --source http://gems.judofyr.net/ Because we recently had a release, this patch is the only difference between the development version and the latest released version of Camping. So it should be pretty safe to use that :-) From uzleepito at gmail.com Tue Oct 11 14:46:55 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Tue, 11 Oct 2011 20:46:55 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: > This is a bug in Camping which has been fixed in 5423c7a0. > > You can install the latest development version of Camping by running: > > gem install camping --source http://gems.judofyr.net/ > > Because we recently had a release, this patch is the only difference > between the development version and the latest released version of > Camping. So it should be pretty safe to use that :-) > Thanks! I had to hack a bit in camping-2.1.469.gemspec, but now it works. :) u -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Tue Oct 11 14:55:47 2011 From: judofyr at gmail.com (Magnus Holm) Date: Tue, 11 Oct 2011 20:55:47 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: On Tue, Oct 11, 2011 at 20:46, Nokan Emiro wrote: > Thanks!?? I had to hack a bit in camping-2.1.469.gemspec, > but now it works. :) > > u Damn, I hate these issues with YAML and gemspecs :/ I uploaded a new version that hopefully will install nicely on 1.8 too. Could you try to re-install it in 1.8 to see if there's still a problem? gem install camping --source http://gems.judofyr.net/ If there's still a problem, could you report the error here? And thank you very much for the help :-) From uzleepito at gmail.com Tue Oct 11 15:04:26 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Tue, 11 Oct 2011 21:04:26 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: It has still the same 4 problematic lines: s.date = %q{2011-10-11 00:00:00.000000000Z} ... s.add_development_dependency(%q, ["# 0.8.7"]) ... s.add_dependency(%q, ["# 0.8.7"]) ... s.add_dependency(%q, ["# 0.8.7"]) -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Wed Oct 12 04:02:50 2011 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 12 Oct 2011 10:02:50 +0200 Subject: run my Camping app as a Rack app In-Reply-To: References: Message-ID: On Tue, Oct 11, 2011 at 18:21, Nokan Emiro wrote: > Thanks for the explanation. > > I have had the create method in my application, it calls > Models::create_scheme, because I have migrations too. > (Everything encapsulated, that's what I like about Camping.) > > Actually the problem with X.create was that my > fastcgi-camping-server did not initialize any ActiveRecord > connections, while the standard camping server did.? After I > placed this > > ActiveRecord::Base.establish_connection( > ??????? :adapter? => "mysql", > ??????? :host???? => "localhost", > ??????? :user???? => "*****", > ??????? :password => "******", > ??????? :database => "databasename" > ) > > before the X.create line, it worked fine.? Anyway that generated > a question.? As you can see I replaced sqlite to mysql, > and now I can see in the mysql database, that table names > are in form of databasename_tablename, and I have an extra > databasename_schema_infos table too.? How can I turn this > behavior off?? It's not critical, but a bit ugly. > > uzlee This should remove the prefix: def ActiveRecord::Base.table_name_prefix; '' end You probably don't want to get rid of schema_infos though, since that's kinda essential for migrations. From uzleepito at gmail.com Wed Oct 12 15:07:17 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Wed, 12 Oct 2011 21:07:17 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: > Thanks! I had to hack a bit in camping-2.1.469.gemspec, > but now it works. > I'm sorry to say this but it still does not work. :( I was incautious. After the redirect it shows the right URL in the browser. That's fine, but now I can't access my controllers. The redirect URL is ok, but the content is always from the < R '/' controller. For example if I have Index < R '/', a List < R '/list' and an Add < R '/add' controllers, only / is accessible, www.xxx.com/list and www.xxx.com/add goes somehow to Index. And R() calls in the view makes wrong href values. If the current URL is www.xxx.com/list (which now goes to the controller Index) and I click a link generated to controller Add, it sends me to www.xxx.com/list/add . The worst of all is that everything works fine with all other handlers except Rack::Handler::FastCGI. u. -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Wed Oct 12 15:24:58 2011 From: judofyr at gmail.com (Magnus Holm) Date: Wed, 12 Oct 2011 21:24:58 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: On Wed, Oct 12, 2011 at 21:07, Nokan Emiro wrote: > >> Thanks!?? I had to hack a bit in camping-2.1.469.gemspec, >> but now it works. > > > I'm sorry to say this but it still does not work.? :( ?? I was incautious. > > After the redirect it shows the right URL in the browser.? That's fine, > but now I can't access my controllers.? The redirect URL is ok, but > the content is always from the < R '/' controller. For example if I have > Index < R '/', a List < R '/list' and an Add < R '/add' controllers, > only / is accessible,? www.xxx.com/list and www.xxx.com/add > goes somehow to Index.? And R() calls in the view makes > wrong href values.? If the current URL is www.xxx.com/list (which > now goes to the controller Index) and I click a link generated to > controller Add, it sends me to www.xxx.com/list/add . > > The worst of all is that everything works fine with all other > handlers except Rack::Handler::FastCGI. > > u. It seems to me that PATH_INFO is still not properly handled, but that it's always empty. From uzleepito at gmail.com Wed Oct 12 16:20:59 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Wed, 12 Oct 2011 22:20:59 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: > > It seems to me that PATH_INFO is still not properly handled, but that > it's always empty. > You are right, PATH_INFO is always empty. If I fill it with the $SCRIPT_NAME value, controllers can be accessed again. But links generated by R() are still wrong: a 'Add', :href => R(Add) on a page xxx.com/list goes to xxx.com/list/add, not to xxx.com/add . -------------- next part -------------- An HTML attachment was scrubbed... URL: From judofyr at gmail.com Thu Oct 13 03:17:18 2011 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 13 Oct 2011 09:17:18 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: On Wed, Oct 12, 2011 at 22:20, Nokan Emiro wrote: >> It seems to me that PATH_INFO is still not properly handled, but that >> it's always empty. > > You are right, PATH_INFO is always empty.? If I fill it with the > $SCRIPT_NAME > value, controllers can be accessed again.? But links generated by R() are > still wrong: > > a 'Add', :href => R(Add) > > on a page xxx.com/list goes to xxx.com/list/add, not to xxx.com/add . SCRIPT_NAME is the mount-path. PATH_INFO is the internal app-path. So if you want your application available at xxx.com/my_app/, then the request xxx.com/my_app/add will look like this: SCRIPT_NAME="/my_app" PATH_INFO="/add" If it's available at xxx.com/, then xxx.com/add will look like this: SCRIPT_NAME="" PATH_INFO="/add" Camping uses PATH_INFO for route dispatching and SCRIPT_NAME for route generating. In this case you probably want to explicitly set SCRIPT_NAME to "". From deveritt at innotts.co.uk Thu Oct 13 11:48:28 2011 From: deveritt at innotts.co.uk (Dave Everitt) Date: Thu, 13 Oct 2011 16:48:28 +0100 Subject: Passenger, Rack and __END__ error Message-ID: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> I might be missing something stupid.. but Passenger doesn't like __END__ http://pastie.org/2689517 Same code (omitting requires) fine in Camping server, not with Passenger/Rack: compile error config.ru:33: syntax error, unexpected $end, expecting ')' __END__ ^ Works fine under Passenger without __END__ - probably a Rack issue, but looking for clues here... Ruby 1.8.6 Rack 1.3.4 Passenger 3.0.9 Apache 2.2.17 Camping 2.1.467 DaveE BTW love @@/styles.css - saved 6 lines of code :-) From judofyr at gmail.com Thu Oct 13 14:02:04 2011 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 13 Oct 2011 20:02:04 +0200 Subject: Passenger, Rack and __END__ error In-Reply-To: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> Message-ID: Try to split it up in two files: app.rb: The app config.ru: require 'app' run Nuts I don't think rackup-files can have __END__. // Magnus Holm On Thu, Oct 13, 2011 at 17:48, Dave Everitt wrote: > I might be missing something stupid.. but Passenger doesn't like __END__ > > http://pastie.org/2689517 > > Same code (omitting requires) fine in Camping server, not with > Passenger/Rack: > > compile error config.ru:33: syntax error, unexpected $end, expecting ')' > __END__ ^ > > Works fine under Passenger without __END__ - probably a Rack issue, but > looking for clues here... > > Ruby 1.8.6 > Rack 1.3.4 > Passenger 3.0.9 > Apache 2.2.17 > Camping 2.1.467 > > DaveE > BTW love @@/styles.css - saved 6 lines of code :-) > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From uzleepito at gmail.com Thu Oct 13 15:16:37 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Thu, 13 Oct 2011 21:16:37 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: > SCRIPT_NAME is the mount-path. > PATH_INFO is the internal app-path. > > So if you want your application available at xxx.com/my_app/, then the > request xxx.com/my_app/add will look like this: > > SCRIPT_NAME="/my_app" > PATH_INFO="/add" > > If it's available at xxx.com/, then xxx.com/add will look like this: > > SCRIPT_NAME="" > PATH_INFO="/add" > > Camping uses PATH_INFO for route dispatching and SCRIPT_NAME for route > generating. > > In this case you probably want to explicitly set SCRIPT_NAME to "". Thanks for these infos, it made everything clear. Actually Camping is not working in this way. My app has a whole domain, so it is the second case, where xxx.com/add is my Add controller's path. But I have to force "/" into SCRIPT_NAME to work. If SCRIPT_NAME is empty, Camping generates strange values on R(Add). Maybe this is a bug, I don't know, but this is what I discovered. -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Thu Oct 13 15:25:31 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Thu, 13 Oct 2011 21:25:31 +0200 Subject: how to catch 404s? Message-ID: How can I hide/catch the "Camping problem! /xxx not found" pages? It would be great to define my own handler instead, or simply redirect to the root of my app. -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Thu Oct 13 15:33:24 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Thu, 13 Oct 2011 21:33:24 +0200 Subject: which view am I inside? Message-ID: How can I guess the view's name in my layout method? It would be great to know because of highlight the current menu item the user has selected. Of course I can store it in a variable in my controller just before I call render :view, but I hope there's a much more sexy way to do this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at waechter.wiz.at Thu Oct 13 15:00:41 2011 From: matthias at waechter.wiz.at (=?UTF-8?B?TWF0dGhpYXMgV8OkY2h0ZXI=?=) Date: Thu, 13 Oct 2011 21:00:41 +0200 Subject: Passenger, Rack and __END__ error In-Reply-To: References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> Message-ID: <4E973559.1010509@waechter.wiz.at> On 13.10.2011 20:02, Magnus Holm wrote: > I don't think rackup-files can have __END__. https://github.com/rack/rack/blob/master/test/builder/end.ru ? Matthias From judofyr at gmail.com Thu Oct 13 16:08:56 2011 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 13 Oct 2011 22:08:56 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: On Thu, Oct 13, 2011 at 21:16, Nokan Emiro wrote: > >> SCRIPT_NAME is the mount-path. >> PATH_INFO is the internal app-path. >> >> So if you want your application available at xxx.com/my_app/, then the >> request xxx.com/my_app/add will look like this: >> >> ?SCRIPT_NAME="/my_app" >> ?PATH_INFO="/add" >> >> If it's available at xxx.com/, then xxx.com/add will look like this: >> >> ?SCRIPT_NAME="" >> ?PATH_INFO="/add" >> >> Camping uses PATH_INFO for route dispatching and SCRIPT_NAME for route >> generating. >> >> In this case you probably want to explicitly set SCRIPT_NAME to "". > > Thanks for these infos, it made everything clear.? Actually Camping > is not working in this way.? My app has a whole domain, so it is > the second case, where xxx.com/add is my Add controller's path. > But I have to force "/" into SCRIPT_NAME to work.? If SCRIPT_NAME > is empty, Camping generates strange values on R(Add).? Maybe > this is a bug, I don't know, but this is what I discovered. So you solved your problem? Good :-) If you have some extra time, could you add this controller: class Debug < R '/debug-for-judofyr' def get [@env["PATH_INFO"], @env["SCRIPT_NAME"], R(Add)].inspect end end ? explicitly set SCRIPT_NAME to empty, and then report the result you get at /debug-for-judofyr? From judofyr at gmail.com Thu Oct 13 16:35:28 2011 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 13 Oct 2011 22:35:28 +0200 Subject: how to catch 404s? In-Reply-To: References: Message-ID: module MyApp def r404(path) "404: #{path}" # or you can render a template: render :four_oh_four end end There's also r500(klass,method,exception) which gets called when an exception happens, and r501(method) which gets called when a route is found, but the controller doesn't have the method. // Magnus Holm On Thu, Oct 13, 2011 at 21:25, Nokan Emiro wrote: > How can I hide/catch the "Camping problem! /xxx not found" pages? > It would be great to define my own handler instead, or simply > redirect to the root of my app. > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > From judofyr at gmail.com Thu Oct 13 16:42:01 2011 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 13 Oct 2011 22:42:01 +0200 Subject: which view am I inside? In-Reply-To: References: Message-ID: On Thu, Oct 13, 2011 at 21:33, Nokan Emiro wrote: > How can I guess the view's name in my layout method? > > It would be great to know because of highlight the current > menu item the user has selected.? Of course I can store it in > a variable in my controller just before I call render :view, but I > hope there's a much more sexy way to do this. If you're using Markaby (that is, templates written in Ruby under MyApp::Views) and Ruby 1.9 you can use __method__: module App::Views def foo p "I'm inside: #{__method__}" end end But you can't use that in a layout or partial though (it would just return "layout" or the name of the partial)? From judofyr at gmail.com Thu Oct 13 16:54:54 2011 From: judofyr at gmail.com (Magnus Holm) Date: Thu, 13 Oct 2011 22:54:54 +0200 Subject: Passenger, Rack and __END__ error In-Reply-To: <4E973559.1010509@waechter.wiz.at> References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> <4E973559.1010509@waechter.wiz.at> Message-ID: 2011/10/13 Matthias W?chter : > On 13.10.2011 20:02, Magnus Holm wrote: >> >> I don't think rackup-files can have __END__. > > https://github.com/rack/rack/blob/master/test/builder/end.ru > > ? Matthias It's broken: https://github.com/rack/rack/pull/253 (it only handles one line of content) From uzleepito at gmail.com Thu Oct 13 17:22:44 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Thu, 13 Oct 2011 23:22:44 +0200 Subject: Camping into production In-Reply-To: References: Message-ID: > > class Debug < R '/debug-for-judofyr' > def get > [@env["PATH_INFO"], @env["SCRIPT_NAME"], R(Add)].inspect > end > end > > ? explicitly set SCRIPT_NAME to empty, and then report the result you > get at /debug-for-judofyr? > The wrong one: ["/debug-for-judofyr", "/debug-for-judofyr", "/add"] The good one: ["/debug-for-judofyr", "", "/add"] I have to apologize you, it's not a Camping bug. It's an nginx one. fastcgi_param SCRIPT_NAME $fastcgi_script_name; pushes the wrong value into SCRIPT_NAME. This is in an external config file so I didn't realize it. If I define SCRIPT_NAME as "/" or "" in the main config, it overwrites the $fastcgi_script_name value, and my app works fine. (With "/" as well as with "".) u. -------------- next part -------------- An HTML attachment was scrubbed... URL: From uzleepito at gmail.com Thu Oct 13 17:36:28 2011 From: uzleepito at gmail.com (Nokan Emiro) Date: Thu, 13 Oct 2011 23:36:28 +0200 Subject: which view am I inside? In-Reply-To: References: Message-ID: > > > > How can I guess the view's name in my layout method? > > If you're using Markaby (that is, templates written in Ruby under > MyApp::Views) and Ruby 1.9 you can use __method__: > > module App::Views > def foo > p "I'm inside: #{__method__}" > end > end > > But you can't use that in a layout or partial though (it would just > return "layout" or the name of the partial)? > My question was about the layout. Suppose that Alfa and Beta are menu items in the layout, and I want to mark the current menu item with different appearance: module App::Views def layout case ..... #<--- Which view am I currently rendering? :alfa or :beta? when :alfa # generate an alfa-selected menu when :beta # generate a beta-item-selected menu end div(:class => :content) { self << yield } end def alfa "Alfa" end def beta "Beta" end end -------------- next part -------------- An HTML attachment was scrubbed... URL: From a at creativepony.com Thu Oct 13 19:15:57 2011 From: a at creativepony.com (Jenna Fox) Date: Fri, 14 Oct 2011 10:15:57 +1100 Subject: how to catch 404s? In-Reply-To: References: Message-ID: Check out Error handling down the bottom of this page: http://camping.rubyforge.org/book/51_upgrading.html ? Jenna On 14/10/2011, at 6:25 AM, Nokan Emiro wrote: > How can I hide/catch the "Camping problem! /xxx not found" pages? > It would be great to define my own handler instead, or simply > redirect to the root of my app. > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias at waechter.wiz.at Fri Oct 14 02:55:59 2011 From: matthias at waechter.wiz.at (=?UTF-8?B?TWF0dGhpYXMgV8OkY2h0ZXI=?=) Date: Fri, 14 Oct 2011 08:55:59 +0200 Subject: Passenger, Rack and __END__ error In-Reply-To: References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> <4E973559.1010509@waechter.wiz.at> Message-ID: <4E97DCFF.3090803@waechter.wiz.at> On 13.10.2011 22:54, Magnus Holm wrote: > 2011/10/13 Matthias W?chter: >> On 13.10.2011 20:02, Magnus Holm wrote: >>> >>> I don't think rackup-files can have __END__. >> >> https://github.com/rack/rack/blob/master/test/builder/end.ru >> >> ? Matthias > > It's broken: https://github.com/rack/rack/pull/253 (it only handles > one line of content) right. This will probably never work, though: [http://pastie.org/2693243] ? Matthias From judofyr at gmail.com Fri Oct 14 03:19:11 2011 From: judofyr at gmail.com (Magnus Holm) Date: Fri, 14 Oct 2011 09:19:11 +0200 Subject: which view am I inside? In-Reply-To: References: Message-ID: On Thu, Oct 13, 2011 at 23:36, Nokan Emiro wrote: > My question was about the layout.? Suppose that Alfa and Beta are > menu items in the layout, and I want to mark the current menu item > with different appearance: > > > module App::Views > ? def layout > ??? case .....? #<--- Which view am I currently rendering? ? :alfa or :beta? > ????? when :alfa > ??????? # generate an alfa-selected menu > ????? when :beta > ??????? # generate a beta-item-selected menu > ??? end > ??? div(:class => :content) { > ?? ?? self << yield > ??? } > ? end > > ? def alfa > ??? "Alfa" > ? end > > ? def beta > ??? "Beta" > ? end > end You could always override the render-method yourself: module App::Helpers def render(name, *rest) @template_name = name.to_s unless name == :layout super end end module App::Views def layout h1 "I'm in #{@template_name}" self << yield end end From judofyr at gmail.com Fri Oct 14 03:20:36 2011 From: judofyr at gmail.com (Magnus Holm) Date: Fri, 14 Oct 2011 09:20:36 +0200 Subject: Passenger, Rack and __END__ error In-Reply-To: <4E97DCFF.3090803@waechter.wiz.at> References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> <4E973559.1010509@waechter.wiz.at> <4E97DCFF.3090803@waechter.wiz.at> Message-ID: > right. > > This will probably never work, though: [http://pastie.org/2693243] > > ? Matthias Woah, I never realized that __END__ was valid on its own line inside a heredoc/string? From matthias at waechter.wiz.at Fri Oct 14 04:04:11 2011 From: matthias at waechter.wiz.at (=?UTF-8?B?TWF0dGhpYXMgV8OkY2h0ZXI=?=) Date: Fri, 14 Oct 2011 10:04:11 +0200 Subject: Passenger, Rack and __END__ error In-Reply-To: References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> <4E973559.1010509@waechter.wiz.at> <4E97DCFF.3090803@waechter.wiz.at> Message-ID: <4E97ECFB.3020903@waechter.wiz.at> On 14.10.2011 09:20, Magnus Holm wrote: >> right. >> >> This will probably never work, though: [http://pastie.org/2693243] >> >> ? Matthias > > Woah, I never realized that __END__ was valid on its own line inside a > heredoc/string? and it?s valid within a multiline comment, too: =begin ? __END__ ? =end and this, again, is valid within a heredoc. Try: a = < References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> <4E973559.1010509@waechter.wiz.at> <4E97DCFF.3090803@waechter.wiz.at> Message-ID: <4E97F716.7000706@waechter.wiz.at> On 14.10.2011 08:55, Matthias W?chter wrote: > This will probably never work, though: [http://pastie.org/2693243] I filed that as a Rack bug. Maybe it gets fixed someday. https://github.com/rack/rack/issues/254 ? Matthias From deveritt at innotts.co.uk Fri Oct 14 09:33:34 2011 From: deveritt at innotts.co.uk (Dave Everitt) Date: Fri, 14 Oct 2011 14:33:34 +0100 Subject: Passenger, Rack and __END__ error In-Reply-To: References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> Message-ID: Thanks - that worked :-) - DaveE > Try to split it up in two files: > > app.rb: The app > > config.ru: > require 'app' > run Nuts > > I don't think rackup-files can have __END__. > > // Magnus Holm > > On Thu, Oct 13, 2011 at 17:48, Dave Everitt > wrote: >> I might be missing something stupid.. but Passenger doesn't like >> __END__ >> >> http://pastie.org/2689517 >> >> Same code (omitting requires) fine in Camping server, not with >> Passenger/Rack: >> >> compile error config.ru:33: syntax error, unexpected $end, >> expecting ')' >> __END__ ^ >> >> Works fine under Passenger without __END__ - probably a Rack issue, >> but >> looking for clues here... >> >> Ruby 1.8.6 >> Rack 1.3.4 >> Passenger 3.0.9 >> Apache 2.2.17 >> Camping 2.1.467 >> >> DaveE >> BTW love @@/styles.css - saved 6 lines of code :-) From deveritt at innotts.co.uk Fri Oct 14 09:59:10 2011 From: deveritt at innotts.co.uk (Dave Everitt) Date: Fri, 14 Oct 2011 14:59:10 +0100 Subject: Passenger, Rack and __END__ error In-Reply-To: <4E97DCFF.3090803@waechter.wiz.at> References: <13CB8BDA-FF5E-4C75-AF4A-2FDEA80D1820@innotts.co.uk> <4E973559.1010509@waechter.wiz.at> <4E97DCFF.3090803@waechter.wiz.at> Message-ID: >> It's broken: https://github.com/rack/rack/pull/253 (it only handles >> one line of content) noted > This will probably never work, though: [http://pastie.org/2693243] Wow. That's probably for the best... DaveE