Re: Help with Controllers
On Mon, Aug 29, 2011 at 8:47 PM, Anonymous Waffles theonetruewaff...@gmail.com wrote: Hello guys, I'm new to the Ruby, and especially to Camping. I've been having some difficulty because there aren't that many tutorials about Camping compared to other larger frameworks. I've been building some small stuff recently to learn about how it work, but I've puzzles as to how user input in a textbox is processed. Here's some code from the awfully short yet extremely informative Camping Book: module Nuts::Views def edit h1 @page.title form :action = R(PageX, @page.title), :method = :post do textarea @page.content, :name = :content, :rows = 10, :cols = 50 br input :type = :submit, :value = Submit! end end end It's apparent that since the input is encased in the textarea block, it send the value when clicked. the :action says what class to send it to, and :method which method. *The docs say that the R() syntax is for creating a path. Could I simply use the name of a controller instead, if it's in the same Ruby file?* No. A form's action attribute requires a path or a URL. Controllers are not usually meaningful paths. Therefore, you should continue to use the R() function to generate paths. An alternative to using the R() function would be to generate a path yourself. /page/#{@page.title} -- That would work, but I personally recommend sticking to using the R() function. It gives you the freedom to tweak the URL structure of your web app with minimal pain. And how is it sent along? Must the post method have a certain argument? Let's pretend this is our PageX controller: class PageX def get(title) @page = H.new @page.title = title render :page end def post(title) content = *@input.content* # do something with content and then... redirect R(PageX, title) end end When someone submits the form you made, the post() method of the PageX controller will be run, and all the form variables will be in @input. Hope that helps. --beppu PS: A question for those who have deep Camping knowledge Since when did Camping support Simpler Routes as described in http://camping.rubyforge.org/book/02_getting_started.html ? I had no idea until just a few minutes ago that capital N and X had a special meaning in controller names. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Feature: Inline templates?
I was fine with Markaby. On Thu, Aug 25, 2011 at 11:04 AM, Magnus Holm judo...@gmail.com wrote: Another feature! Inline templates: module App::Controllers get '/' do @title = My Perfect App render :index end end __END__ @@ index.erb Welcome to %= @title % What'd you think? Keep or throw away? It costs us 184 bytes at the moment. // Magnus Holm ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Feature: Simple controllers?
If I wanted that notation, I'd just use Sinatra. ;) Like Bartosz, I like having named controllers so that I can pass them to R() when generating links. On Thu, Aug 25, 2011 at 10:20 AM, Magnus Holm judo...@gmail.com wrote: I just pushed a new feature to Camping: Simple controllers. module App::Controllers get '/(.*)' do |name| Hello #{name} end end What do you think? Useful? Or should I revert it? It currently costs us 87 bytes. // Magnus Holm ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Feature: Simple controllers?
Being able to name controllers definitely makes it more valuable. If I had to criticize Sinatra and its clones, I would criticize their lack of named controllers. It's difficult to write URL generation functions without them. I've only seen one Sinatra clone (Slim in php) that allows controllers to be named. On Thu, Aug 25, 2011 at 2:21 PM, Magnus Holm judo...@gmail.com wrote: On Aug 25, 2011 10:54 PM, John Beppu john.be...@gmail.com wrote: If I wanted that notation, I'd just use Sinatra. ;) Like Bartosz, I like having named controllers so that I can pass them to R() when generating links. Does it make it better that you can name them too? Index = get / do ... end Sent from my iCampingPhone ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: sending a post request from a controller
I have a bad feeling about whatever you're trying to do. However, I want to make sure that my interpretation of your intent is correct. 1. It sounds like you want to create a web app that provides a form. 2. When this form is submitted (and assuming the data is valid), you want to POST this data to a URL at https://www.salliemae.com/. 3. Then, it sounds like you want to send a redirect so that the user of your webapp ends up at an appropriate page at https://www.salliemae.com/(possibly with a prefilled form courtesy of your work). If this is the case, you have a big problem -- salliemae.com login info is needed in too many places. Step 2 (which happens on the server side) needs the user's Sallie Mae login credentials in order to perform a successful POST, and that's unwise to give out. Your users should never have to trust you with their Sallie Mae username and password. That should be private information, never to be given out to 3rd parties (including you). Step 3 also requires that the user's browser already be logged in to salliemae.com or the redirect wouldn't work. I have the feeling that you're trying to simplify a person's user experience by prefilling a cumbersome form, but your strategy for doing this may be flawed. --beppu On Sun, Jul 3, 2011 at 8:06 PM, David Susco dsu...@gmail.com wrote: They do not, pretty much they need a few input tags and that's about it. I'm just looking to do my form validation/preparation server-side instead of client-side. Dave On Sun, Jul 3, 2011 at 9:35 PM, John Beppu john.be...@gmail.com wrote: Does Sallie Mae provide a payment processing API? I searched for it, but I couldn't find anything. On Sun, Jul 3, 2011 at 4:46 AM, David Susco dsu...@gmail.com wrote: None of those, I'm in education, and we have to go through Sallie Mae. Dave On Sun, Jul 3, 2011 at 1:16 AM, John Beppu john.be...@gmail.com wrote: Can you tell us what payment processing system you're trying to work with? Is it PayPal or Google Checkout? Bitcoin? ;-) On Thu, Jun 30, 2011 at 6:48 AM, David Susco dsu...@gmail.com wrote: Ideally I'd like a user to be able to submit a form to the camping app, having camping do all the validation and some preprocessing and then have the camping app send the user to an external site (with the post data) where the user can complete a payment. Dave On Wed, Jun 29, 2011 at 5:00 PM, Steve Klabnik st...@steveklabnik.com wrote: No, redirects are an HTTP response, they're not a new request. Can you give a more concrete example? Your explanation sounds like you're trying to do two different things, and I'm not sure which you mean. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list -- Dave ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list -- Dave ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list -- Dave ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: sending a post request from a controller
Can you tell us what payment processing system you're trying to work with? Is it PayPal or Google Checkout? Bitcoin? ;-) On Thu, Jun 30, 2011 at 6:48 AM, David Susco dsu...@gmail.com wrote: Ideally I'd like a user to be able to submit a form to the camping app, having camping do all the validation and some preprocessing and then have the camping app send the user to an external site (with the post data) where the user can complete a payment. Dave On Wed, Jun 29, 2011 at 5:00 PM, Steve Klabnik st...@steveklabnik.com wrote: No, redirects are an HTTP response, they're not a new request. Can you give a more concrete example? Your explanation sounds like you're trying to do two different things, and I'm not sure which you mean. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list -- Dave ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Changing render semantics?
On Sat, Apr 24, 2010 at 3:39 PM, Magnus Holm judo...@gmail.com wrote: I guess the question is: Does anybody actually use `render` with multiple arguments (render :index, 1, 2)? If not, I guess we can easily switch to this new `render` without breaking code. I do not use the multi-argument form of render. I didn't even know you could do that. --beppu ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: [ANN] Camping 2.0 - minature rails for stay-at-home moms
Good job. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: what is this log mean?
It means that someone sent you an invalid HTTP request, and this is Mongrel's noisy way of rejecting it. Don't worry. It's harmless. --beppu On Mon, Jan 18, 2010 at 12:27 AM, in-seok hwang his20...@gmail.com wrote: Hi, all my server spec is .. camping -1.5.180 mongrel-1.1.5 4~5 times a day i will see the log . But , i don't know this message's mean . The following is the log. Sun Jan 17 18:25:19 +0900 2010: HTTP parse error, malformed request (125.230.144.181): #Mongrel::HttpParserError: Invalid HTTP format, parsing fails. Sun Jan 17 18:25:19 +0900 2010: REQUEST DATA: \005\001\000 --- PARAMS: {} --- Sun Jan 17 18:25:20 +0900 2010: Read error: #URI::InvalidURIError: bad URI(is not URI?): 203.188.201.253:25 /usr/lib/ruby/1.8/uri/common.rb:436:in `split' /usr/lib/ruby/1.8/uri/common.rb:485:in `parse' /usr/local/lib/site_ruby/1.8/mongrel.rb:127:in `process_client' /usr/local/lib/site_ruby/1.8/mongrel.rb:285:in `run' /usr/local/lib/site_ruby/1.8/mongrel.rb:285:in `initialize' /usr/local/lib/site_ruby/1.8/mongrel.rb:285:in `new' /usr/local/lib/site_ruby/1.8/mongrel.rb:285:in `run' /usr/local/lib/site_ruby/1.8/mongrel.rb:268:in `initialize' /usr/local/lib/site_ruby/1.8/mongrel.rb:268:in `new' /usr/local/lib/site_ruby/1.8/mongrel.rb:268:in `run' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:282:in `run' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:281:in `each' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:281:in `run' conf_mongrel.rb:2070:in `cloaker_' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:149:in `call' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:149:in `listener' conf_mongrel.rb:2066:in `cloaker_' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:50:in `call' /usr/local/lib/site_ruby/1.8/mongrel/configurator.rb:50:in `initialize' conf_mongrel.rb:2065:in `new' conf_mongrel.rb:2065 what is this? ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: What now?
On Mon, Oct 19, 2009 at 11:03 AM, Julik Tarkhanov julian.tarkha...@gmail.com wrote: On 19 Oct 2009, at 14:27, Dave Everitt wrote: nice idea with the .ru = Ruby, although still doubtful that 'why' and 'went' are good for SEO (BTW you did mean 'camping', not 'caping' didn't you :-). Registering domains in Russia is a bit risky IMO. Out of (morbid) curiosity, what are the risks of registering a .ru domain? --beppu ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: What now?
I like the domain whywentcamping.com . ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: hi all! can't open github!!
It's a little slow over at github, but the page loads for me (sometimes). They must be experiencing a lot of traffic. --beppu On Sun, Aug 16, 2009 at 6:59 PM, in-seok hwang his20...@gmail.com wrote: hi all! can't open github (http://github.com/why/camping/tree/master) What's going on? ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: hi! plz teach me! about file upload
Something like this should work for the old version of Camping: class Upload R '/upload' def get render :upload end def post upload = @input.upload filename = File.basename(upload.filename) puts @input.upload[:tempfile].path puts filename File.link(upload[:tempfile].path, filename) redirect R(Home) end end # the :upload view def upload form.upload(:method = 'post', :enctype = 'multipart/form-data', :action = R(Upload)) { input :type = 'file', :name = 'upload' input.post.button :type = 'submit', :name = 'submit', :value = 'POST' } end 2009/4/1 in-seok hwang his20...@gmail.com oh... sorry. i can't use current version. I had a lot of code writing. i used 1.5.180 camping version. when i upgrade to the latest version is a lot of errors. but, I want to use the latest version. Anyway, how do upload file in 1.5.180 ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: images in db
Roland just showed you how to inline it. Here's a little article on the technique he's using: http://jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images However, as Jenna said, this technique doesn't work in IE. Her first suggestion is probably the path of least resistance. --beppu On Tue, Feb 3, 2009 at 5:35 AM, Cornelius Jaeger cjli...@visualfood.chwrote: Hi Jenna, Roland Thanks for your responses. How can I get the image inline in the html, rather than downloading it to the user? I'm not at all sure how to use markaby to stream the image data into something the img tag will understand. Many Thanks for helping Cornelius On 03.02.2009, at 01:58, Jenna Fox wrote: Make a controller with a get method to retrieve the image, then, have some code like this in it, supposing image_data is a string or something: headers['Content-Type'] = 'image/png' headers['Content-Length'] = image_data.length.to_s return image_data On 03/02/2009, at 10:58 AM, Cornelius Jaeger wrote: hi all just working on my first camping hack and new to ruby as well. i've figured some things out and uploading images into the database, but i'm not sure how to get the data displayed in the browser. i'd like to stream it straight from the db, not copy it to the fs first. obviously img(:src = file_data) doesn't work. any pointers or reading assignments would be v. welcome. many thanks cornelius ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: My Camping clone has broken the 4K barrier. ;-)
Unfortunately, I am not a master of obfuscation. I don't know where the masters went, either. Back in the day, there were some talented ASCII artists working in Perl, but it's like they've gone extinct. On Thu, Dec 4, 2008 at 2:57 AM, Magnus Holm [EMAIL PROTECTED] wrote: Well done, but I thought Perl would do better... //Magnus On 4. des.. 2008, at 10.37, John Beppu [EMAIL PROTECTED] wrote: Behold! http://gist.github.com/31363http://gist.github.com/31363 4004 bytes! The non-obfuscated version can be found at: http://github.com/beppu/squatting/tree/master http://github.com/beppu/squatting/tree/master --beppu PS: I'm not going to try for 3K. I'm happy that I was even able to reach 4K, and that satisfaction is enough. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: My Camping clone has broken the 4K barrier. ;-)
I think I could easily trim 20-30 bytes from the obfuscated version, but 3K seems so far away. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: [TIP] optional multi-pane layout
That's pretty damned cool. Good technique! --beppu On Thu, Aug 28, 2008 at 3:46 AM, zimbatm [EMAIL PROTECTED] wrote: This is a nice little trick to defer some block execution in a multi-pane layout module Views def layout html do #... body do div.main { yield } div.right! @_right_pane if @_right_pane end end end def _right_pane(block) @_right_pane = block end # So now on your view def some_view # use that method if you need the right pane _right_pane do # Some code in the right pane end # And here goes your regular view end end Cheers, zimbatm ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Camping-list Digest, Vol 23, Issue 8
What pains me is that my Perl clone is weighing in at a bloated 6.6k after I run it through: cat `find -name '*.pm' -print` | perltidy -npro -dac -dws -i 0 | sed '/^\s*$/d' | perl -pe 's/ +/ /g' | wc . I was never an expert golfer http://perlgolf.sourceforge.net/, but still *sigh* --beppu On Thu, May 22, 2008 at 11:34 AM, John Baylor [EMAIL PROTECTED] wrote: Removed 25% of the framework? Gosh, I wish _why wasn't so darn verbose... ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Squatting
On 5/15/08, zimbatm [EMAIL PROTECTED] wrote: Haha, well done :) Small rectification: Camping also allows multiple views per controller Really? How do you set up multiple views for a Camping app? ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: query strings built by R method can't handle multiple values from checkbox selections
As an side, I'm writing a Camping-like framework in Perl, and R() is still on my to-do list. I'm glad you posted this, because I probably would've ended up duplicating that bug in my translation to Perl. --beppu On Thu, May 8, 2008 at 7:58 AM, Ronald Evangelista [EMAIL PROTECTED] wrote: query strings built by R method can't handle multiple values from checkbox selections R(SomeRoute, :reply_status=%w{1 2 4}) should return query_string= http://localhost:3301/someroute/?reply_status_id=1reply_status_id=2reply_status_id=4 qsp(query_string) - {reply_status_id=[1, 2, 4]} from camping_unabridged.rb def R(c,*g) p,h=/\(.+?\)/,g.grep(Hash) g-=h raise bad route unless u = c.urls.find{|x| break x if x.scan(p).size == g.size /^#{x}\/?$/ =~ (x=g.inject(x){|x,a| x.sub p,C.escape((a[a.class.primary_key]rescue a))}) } h.any?? u+?+h[0].map{|x|x.map{|z|C.escape z}*=}*: u end i think it would work if modified as: h[0].map{|x| k, v=x if v.is_a?Array v.map{|v2| [C.escape( k), C.escape( v2)]*=} * else x.map{|z| C.escape z}*= end }* ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
[poll] What was your primary language before you started coding in Ruby?
This is an informal poll. If you are primarily a Ruby programmer, - What was your primary language before you started coding in Ruby? Else, - What's your current programming language of choice? I'll start: Perl ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Camping is a winner at SXSW-i
Last night, a little Camping application I wrote called MetaNoteshttp://www.metanotes.com/won the Experimental division in the SXSW Web Awardshttp://2008.sxsw.com/interactive/web_awards/finalists/ . MetaNotes is a site that lets you (and many other people) simultaneously place colorful post-it notes on a wide canvas. If you get lucky, you may see notes move in the background as other people (or robots) make changes to the space you happen to be in. I must warn you that it's very alpha at the moment, so be gentle with the site. In my estimation, it's only about 60% done, and we were surprised to even be finalists. Anyway, I'm writing this email to thank everyone who worked on Camping and made it the beautiful little web microframework that it is. My favorite part of Camping is the way controllers are expressed. It gives me so much control over URLs, and I love how the controllers are RESTful by default. That was a brilliant idea. --beppu PS: During the web awards, we must've been sitting at the lucky table. There were 3 teams at the table, and at the end of the night, that table had 4 awards. I wish I had taken a picture. (The MetaNotes crew was sitting w/ people from Wikinvest and Launchball. We all won our respective categories, and Launchball won something else at the end.) How crazy is that. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: css image url's and :img problem
On Nov 17, 2007 8:10 PM, pedro mg [EMAIL PROTECTED] wrote: background: #33 url(img01.gif) repeat-x; url(/static/img01.gif) ? ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: Camping and ruby2ruby
On 9/27/07, Jonas Pfenniger [EMAIL PROTECTED] wrote: 2007/9/27, Gregor Schmidt [EMAIL PROTECTED]: Defining NilClass#method_missing for nothing is not too clever, for a large scale libary IMO. I'm not sure you understood, it is ruby2ruby who defined nil.method_missing. We can't start to support each and every hack a library will add to the Ruby core. ^for this reason, you can't really use ruby2ruby in anything serious. nil.method_missing prevents a lot of exceptions from being thrown, and there's a lot of code out their that legitimately needs those exceptions to be thrown for correct behavior. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list