Re: Simplest easiest rss feeds?
On Wed, 5 Oct 2011 11:20:31 +1100, Jenna Fox a...@creativepony.com wrote: [1 multipart/alternative (7bit)] [1.1 text/plain; windows-1252 (quoted-printable)] [1.2 text/html; windows-1252 (quoted-printable)] 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 ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: sqlite3 connection problem
On Tue, Jun 09, 2009 at 11:35:26AM +0100, Dave Everitt wrote: Any feedback appreciated on the following. My most recent attempt to identify the issue is a minimal Ruby/SQLite/ActiveRecord script, Pastied here: http://pastie.textmate.org/492514 which brings up the following when run from the command line (an empty database file already exists): $ ./simple_db.rbx [SNIP]/active_record/connection_adapters/sqlite3_adapter.rb:29:in `table_structure': Could not find table 'users' (1) Not really a 'camping' related pastie. See (3) for the same thing done the 'camping way'. (2) There seems to be nothing in the code above telling activerecord to create your database schema unless you're doing seperate rake db:migrate scripts outside of this script. My suspicion, therefore is that the 'users' table simply does not exist in your database. (3) This is a full working solution for camping 1.5: #!/usr/bin/env ruby $:.unshift File.dirname(__FILE__) + /../../lib require 'camping' Camping.goes :Dave module Dave::Models class User Base end class CreateTables V 1.0 def self.up create_table :dave_users, :force = true do |t| t.column :id, :integer, :null = false t.column :name, :string, :limit = 255 t.column :password, :string, :limit = 255 end def self.down drop_table :dave_users end end end end module Dave::Controllers class Index R '/' def get user = User.new() user.id = dave user.name = Dave Everitt user.password = davepass user.save # user = User.find(dave) # user.destroy() render :fin end end end module Dave::Views def fin Finished, no errors end end def Dave.create Dave::Models.create_schema :assume = (Dave::Models::User.table_exists? ? 1.0 : 0.0) end *** Save this file as dave.rb. Note the Dave::Models.create_schema call (as per point 2 above) To get this to work I have the following gems installed: $ gem list *** LOCAL GEMS *** activerecord (2.3.2) activesupport (2.3.2) builder (2.1.2) camping (1.5.180) markaby (0.5) metaid (1.0) sqlite3-ruby (1.2.4) I run it with: camping dave.rb I then visited http://localhost:3301/ with my browser (which showed Finished, no errors). To confirm that there is a table in the sqlite database with the correct fields and with one record: $ sqlite3 ~/.camping.db SQLite version 3.6.10 Enter .help for instructions Enter SQL statements terminated with a ; sqlite .tables dave_schema_infos dave_users sessions sqlite .header on sqlite select * from dave_users; id|name|password 0|Dave Everitt|davepass Hope some of the above points you in the 'right' direction. Cheers, Jonathan. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
Re: deployment
Hi David, On Wed, Jun 03, 2009 at 10:24:01AM -0400, David Susco wrote: I have a few camping apps I'd like to start automatically if my server ever restarts. There's an init.d file that comes with mongrel_cluster that you can use for rails apps, is there anything out there for camping apps though? With the postamble containing all the configuration for the app, it seems that all the init.d file would have to do is execute the camping file. Has anyone done this/have any pointers? I know this is not exactly what you're asking since your question was mongrel based, but if you were to look at running camping 2.0 with passenger/rack you would get automatic restarts as well as working redirects. Plus you'd be able to also easily deploy rails apps (and even some python apps) with the same setup. Cheers, Jonathan ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list
The subtleties of config.ru, or what to do if you get Camping problem! / not found
On Thursday I tried to get the camping blog.rb example working with rack/passenger/apache. The config.ru (below) resulted in Camping Problem! / not found require 'rubygems' require 'rack' require 'camping' Camping.goes :Blog Blog::Models::Base.establish_connection :adapter = sqlite3, :database = /home/jonathan/.camping.db run Blog This is what it should have in it: require 'rubygems' require 'rack' require 'camping' require 'blog' Blog::Models::Base.establish_connection :adapter = sqlite3, :database = /home/jonathan/.camping.db run Blog When the top version of config.ru is run, it results in the route maker getting a 'constants' array consisting only of [I] (instead of [Style, Logout, Login, PostN, I, Index, PostNew, Edit] ). What magic sets the constants array? (couldn't find it with a quick grep through the code) I guess this is an easy mistake to make (at least for me it was) if you just read the phusion passenger user guide which explicitly says use Camping.goes. So if anyone else sees this message, set config.ru as above. Cheers, Jonathan P.S. one would think that putting a require 'blog' before the Camping.goes and commenting out the Camping.goes in blog.rb would fix things with the first approach, but I stumbled into a whole hornets nest of errors relating to Blog::Models::Base when I tried that. ___ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list