Re: First time on Camping

2010-06-19 Thread Raimon Fernandez
Hi all,

On 18jun, 2010, at 17:51 , Magnus Holm wrote:

 This shouldn't be a problem, because that's the way to add non-ASCII
 characters to XML documents. A proper XML parser should handle it...

But in this case, it's an ASCII á, well, the extended ASCII, and all .xml files 
that I've created never added this encoded, always the char itself, like à á ç ñ

I'm using the TBMXML parser http://www.tbxml.co.uk/TBXML/TBXML_Free.html

And because the xml file has the encoding=UTF-8 I suppose that those chars 
can be added as they are without encoding.

And also I'm using other C libraries in other projects that they do not escape 
those chars ...

Thanks!

regards,

r.


 
 // Magnus Holm (from my phone)
 
 On Friday, June 18, 2010, Raimon Fernandez co...@montx.com wrote:
 Hi again,
 
 I know this is more related to builder than to camping, but not sure where 
 to ask for it ...
 
 :-)
 
 
 My app receives .xml file from some different sources, and all of them, 
 except the camping one, are formatted like this:
 
 
 ?xml version=1.0 encoding=UTF-8?
 person
  nameJim Fernández/name
  phone555-1234/phone
 /person
 
 
 but camping is formatting like this:
 
 ?xml version=1.0 encoding=UTF-8?
 person
  nameJim Fern#225;ndez/name
  phone555-1234/phone
 /person
 
 
 The main difference is the encoding for some chars:
 
 á = #225;
 
 I can't find in builder how to write values without escaping them ...
 
 thanks,
 
 r.
 
 On 17jun, 2010, at 21:04 , Magnus Holm wrote:
 
 And if you want this XML:
 
 ?xml version=1.0 encoding=UTF-8?
 posts
  post
titleHiya/title
contentHey/content
  /post
 /posts
 
 You have this view:
 
 module App::Views
  def posts(xml)
xml.posts do
  @posts.each do |post|
xml.post do
  xml.title(post.title)
  xml.content(post.content)
end
  end
end
  end
 end
 
 
 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list
 
 
 -- 
 // 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: First time on Camping

2010-06-19 Thread Magnus Holm
I think the problem is that Builder don't know that you're using
UTF-8, so it's just doing the safest thing and just escapes
everything. But this shouldn't really be a problem, since the parser
should handle it and treat every #225; as á.

// Magnus Holm



On Sat, Jun 19, 2010 at 15:53, Raimon Fernandez co...@montx.com wrote:
 Hi all,

 On 18jun, 2010, at 17:51 , Magnus Holm wrote:

 This shouldn't be a problem, because that's the way to add non-ASCII
 characters to XML documents. A proper XML parser should handle it...

 But in this case, it's an ASCII á, well, the extended ASCII, and all .xml 
 files that I've created never added this encoded, always the char itself, 
 like à á ç ñ

 I'm using the TBMXML parser http://www.tbxml.co.uk/TBXML/TBXML_Free.html

 And because the xml file has the encoding=UTF-8 I suppose that those chars 
 can be added as they are without encoding.

 And also I'm using other C libraries in other projects that they do not 
 escape those chars ...

 Thanks!

 regards,

 r.



 // Magnus Holm (from my phone)

 On Friday, June 18, 2010, Raimon Fernandez co...@montx.com wrote:
 Hi again,

 I know this is more related to builder than to camping, but not sure where 
 to ask for it ...

 :-)


 My app receives .xml file from some different sources, and all of them, 
 except the camping one, are formatted like this:


 ?xml version=1.0 encoding=UTF-8?
 person
  nameJim Fernández/name
  phone555-1234/phone
 /person


 but camping is formatting like this:

 ?xml version=1.0 encoding=UTF-8?
 person
  nameJim Fern#225;ndez/name
  phone555-1234/phone
 /person


 The main difference is the encoding for some chars:

 á = #225;

 I can't find in builder how to write values without escaping them ...

 thanks,

 r.

 On 17jun, 2010, at 21:04 , Magnus Holm wrote:

 And if you want this XML:

 ?xml version=1.0 encoding=UTF-8?
 posts
  post
    titleHiya/title
    contentHey/content
  /post
 /posts

 You have this view:

 module App::Views
  def posts(xml)
    xml.posts do
     �...@posts.each do |post|
        xml.post do
          xml.title(post.title)
          xml.content(post.content)
        end
      end
    end
  end
 end


 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list


 --
 // 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

___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Re: First time on Camping

2010-06-18 Thread Raimon Fernandez
Hi Magnus,


On 17jun, 2010, at 21:04 , Magnus Holm wrote:

 Hey Raimon,
 
 I see that you've been experimenting with Camping and Reststop lately,
 and just thought I should chime in a bit.
 
 You definitely don't *need* Reststop in order to achieve what you
 want, so it might be a good idea to just leave Reststop until it gets
 a little more robust. Let's see how we can tackle your problem with
 Camping only:

Thanks for your code.


It's true that if I can do what I want with fewer tools/gems, it's a better 
starter, and once I'm confident I can go further.

 That's (hopefully) the simplest way to generate XML with Camping.

yes!


 You still need to create a model to store/retrieve the data. Before we
 can help you here, we need to know a few things: Is it going to fetch
 data from a specific place, or should it create its own database (from
 scratch)? Any specific database you want to use?

Not sure yet, but maybe Sqlite or PostgreSQL. Normally I use PostgreSQL for all 
of my RoR projects, but in this case Sqlite would be simpler.

The initial data will come from some xml files but I can update the database 
from another file with Ruby code. In some examples of Camping they just created 
the database but I couldn't find where they are storing it ...

So, the best option is to provide to Camping an existing SQLite database.


 Here's a Pastie with all the code: http://pastie.org/1008983 (Should
 work on any version of Camping).

thanks, it works and it's very simple :-)

Now I'm playing with your code and examples, thanks again!

regards,

raimon


___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-18 Thread Dave Everitt
Rubygems.org was playing up recently (gems.rubyforge.org forwards to  
it - see previous posts), and this looks like the same issue... Dave E.


Something's not right with your rubygems install maybe try `gem  
update --system` first?


___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-18 Thread Raimon Fernandez

On 17jun, 2010, at 21:04 , Magnus Holm wrote:

 
 That's (hopefully) the simplest way to generate XML with Camping.
 
 You still need to create a model to store/retrieve the data. Before we
 can help you here, we need to know a few things: Is it going to fetch
 data from a specific place, or should it create its own database (from
 scratch)? Any specific database you want to use?
 
 Here's a Pastie with all the code: http://pastie.org/1008983 (Should
 work on any version of Camping).

I'm trying to adapt your pastie to use a sqlite databse, but I'm having some 
errors that I can't see ...

Here's a Pastie with all code: http://pastie.org/1009797

I'm just trying to create with code a simple table called Persons with some 
fields but ...

:-)

Also,  I can't find where is creating the database ...

thanks,

regards,

r.
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-18 Thread Magnus Holm
Yeah, people always get a little confused because you don't need to
define your database when you're using bin/camping (it has a default
SQLite database at ~/.camping.db).

I also see that there's some old, database code here; we definitely
need to update our documentation (yes, I'm working on it!)

First of all, the table name should be list_people (since people
is the plural to person and the table names are always in
lowercase), but you should rather do `create_table Person.table_name`
and `drop_table Person.table_name` because then you don't need to
think about it at all :-)

Secondly, you only need this in order to create the database:

def List.create
  List::Models.create_schema
end

Then it will use a SQLite database at ~/.camping.db (as long as you
start it with `camping list.rb`). This is perfect for just testing
things out (you can also run `camping -C list.rb` to get an IRB
console). Please note that if you only run `camping list.rb`, you'll
have to load the page in the browser before the migrations run.

If you want to use a specific database, you can add this:

def List.create
  List::Models::Base.establish_connection(
:adapter = postgresql,
:username = root,
:password = toor,
:database = list
  )
  List::Models.create_schema
end

Or you might want to add the information in a database.yml file:

---
adapter: postgresql
username: root
password: toor
database: list

And then rather do:

require 'yaml'

def List.create
  List::Models::Base.establish_connection(YAML.load(File.read(database.yml)))
  List::Models.create_schema
end

Please note that if you connect to a database which already has the
tables, DON'T run `List::Models.create_schema` as this will probably
delete the whole database. General rule: you only need migrations to
setup the database.

--

And thirdly: Yes, we are aware of that the migration support isn't
very nice. In the future we hope to have something like:

module List::Models
  class Person
t.string :name
  end
end

def List.create
  List::Models.setup!
end

Until then, you'll have to stick with the current solution :-)


// Magnus Holm



On Fri, Jun 18, 2010 at 11:09, Raimon Fernandez co...@montx.com wrote:

 On 17jun, 2010, at 21:04 , Magnus Holm wrote:


 That's (hopefully) the simplest way to generate XML with Camping.

 You still need to create a model to store/retrieve the data. Before we
 can help you here, we need to know a few things: Is it going to fetch
 data from a specific place, or should it create its own database (from
 scratch)? Any specific database you want to use?

 Here's a Pastie with all the code: http://pastie.org/1008983 (Should
 work on any version of Camping).

 I'm trying to adapt your pastie to use a sqlite databse, but I'm having some 
 errors that I can't see ...

 Here's a Pastie with all code: http://pastie.org/1009797

 I'm just trying to create with code a simple table called Persons with some 
 fields but ...

 :-)

 Also,  I can't find where is creating the database ...

 thanks,

 regards,

 r.
 ___
 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: First time on Camping

2010-06-18 Thread Raimon Fernandez
buf, now I'm lost ...

:-))

no, really, thanks for that info, now I have working as I want ...

:-)


I've tested and created a new databse, and is working also.

I've created a new sqlite3 from terminal and filled-up with some data and now I 
can use this databse from Camping, cool!

And, caping is serving the data with .xml format and I can get it from my 
devices, cool!

I'm going to play more with thise, sure I'll come back with more questions ...

:-)

ah, I always use Thin with Nginx for my RoR instead of Mongrel, I suppose there 
would be no problem with camping ?

and speed: normally it's all very fast, but sometimes, it takes a little bit (3 
or more seconds) to respond camping, and I'm not doing nothing serious at all, 
just the example from pastie.

is because I'm using the development mode instead of production, like in RoR ?

thanks again !

regards,

r.



On 18jun, 2010, at 12:33 , Magnus Holm wrote:

 Yeah, people always get a little confused because you don't need to
 define your database when you're using bin/camping (it has a default
 SQLite database at ~/.camping.db).
 
 I also see that there's some old, database code here; we definitely
 need to update our documentation (yes, I'm working on it!)
 
 First of all, the table name should be list_people (since people
 is the plural to person and the table names are always in
 lowercase), but you should rather do `create_table Person.table_name`
 and `drop_table Person.table_name` because then you don't need to
 think about it at all :-)
 
 Secondly, you only need this in order to create the database:
 
 def List.create
  List::Models.create_schema
 end
 
 Then it will use a SQLite database at ~/.camping.db (as long as you
 start it with `camping list.rb`). This is perfect for just testing
 things out (you can also run `camping -C list.rb` to get an IRB
 console). Please note that if you only run `camping list.rb`, you'll
 have to load the page in the browser before the migrations run.
 
 If you want to use a specific database, you can add this:
 
 def List.create
  List::Models::Base.establish_connection(
:adapter = postgresql,
:username = root,
:password = toor,
:database = list
  )
  List::Models.create_schema
 end
 
 Or you might want to add the information in a database.yml file:
 
 ---
 adapter: postgresql
 username: root
 password: toor
 database: list
 
 And then rather do:
 
 require 'yaml'
 
 def List.create
  List::Models::Base.establish_connection(YAML.load(File.read(database.yml)))
  List::Models.create_schema
 end
 
 Please note that if you connect to a database which already has the
 tables, DON'T run `List::Models.create_schema` as this will probably
 delete the whole database. General rule: you only need migrations to
 setup the database.
 
 --
 
 And thirdly: Yes, we are aware of that the migration support isn't
 very nice. In the future we hope to have something like:
 
 module List::Models
  class Person
t.string :name
  end
 end
 
 def List.create
  List::Models.setup!
 end
 
 Until then, you'll have to stick with the current solution :-)
 
 
 // Magnus Holm
 
 
 
 On Fri, Jun 18, 2010 at 11:09, Raimon Fernandez co...@montx.com wrote:
 
 On 17jun, 2010, at 21:04 , Magnus Holm wrote:
 
 
 That's (hopefully) the simplest way to generate XML with Camping.
 
 You still need to create a model to store/retrieve the data. Before we
 can help you here, we need to know a few things: Is it going to fetch
 data from a specific place, or should it create its own database (from
 scratch)? Any specific database you want to use?
 
 Here's a Pastie with all the code: http://pastie.org/1008983 (Should
 work on any version of Camping).
 
 I'm trying to adapt your pastie to use a sqlite databse, but I'm having some 
 errors that I can't see ...
 
 Here's a Pastie with all code: http://pastie.org/1009797
 
 I'm just trying to create with code a simple table called Persons with some 
 fields but ...
 
 :-)
 
 Also,  I can't find where is creating the database ...
 
 thanks,
 
 regards,
 
 r.
 ___
 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: First time on Camping

2010-06-18 Thread Dave Everitt

Raimon

a few things you probably already know but... just in case!

1.
because of the preceding '.' in '.camping.db' you'll need to use ls - 
al to see the file listed (in the ~ home dir) in your file system.


2.
In Magnus' example settings (database = list) you can also add a  
path to your database as well as its name (unless something's changed  
since I last did it!) e.g.:

database = ./data/mydata.db

3.
The Firefox SQLite Manager is handy for errr.. managing your SQLite  
database:

https://addons.mozilla.org/en-US/firefox/addon/5817/
Note: with SQLite you cannot change column names once they're in the  
database (unless anyone knows better?).


Dave E.

Yeah, people always get a little confused because you don't need to  
define your database when you're using bin/camping (it has a  
default SQLite database at ~/.camping.db).


___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-18 Thread Magnus Holm
Excellent!

Camping uses Rack, so it should be very simple to get it running on
any Ruby web server. Just create a config.ru like this:

  require 'list'
  List.create if List.respond_to?(:create) # call List.create if it exists
  run List # and run the app!

Then you can start it with: `thin start` (when you're in the app directory)

One thing you'll have to remember is that any exceptions which are
raised, won't be rescued inside Camping, but rather be raised all the
way up. Thin (hopefully) catches it somewhere, but you should probably
handle it yourself:

module List
  def r500(klass, method, exception)
# Do some funky things
There was an exception in #{klass}.#{method}: #{exception}
  end
end

You could also use something like http://hoptoadapp.com/ (they have
free plans) which gives you a nice dashboard and sends you an email
every time an exception is raised. Just create an account, run `gem
install toadhopper` and add this to your app:

require 'toadhopper'

module List
  ExceptionHandler = Toadhopper.new(YOUR API KEY)
  def r500(klass, method, exception)
# Send the exception to Hoptoad:
ExceptionHandler.post!(exception)
# Render something for the user. You would probably want to render some XML
# so the client knows something went wrong.
There was an exception in #{klass}.#{method}: #{exception}
  end
end

// Magnus Holm



On Fri, Jun 18, 2010 at 13:23, Raimon Fernandez co...@montx.com wrote:
 buf, now I'm lost ...

 :-))

 no, really, thanks for that info, now I have working as I want ...

 :-)


 I've tested and created a new databse, and is working also.

 I've created a new sqlite3 from terminal and filled-up with some data and now 
 I can use this databse from Camping, cool!

 And, caping is serving the data with .xml format and I can get it from my 
 devices, cool!

 I'm going to play more with thise, sure I'll come back with more questions ...

 :-)

 ah, I always use Thin with Nginx for my RoR instead of Mongrel, I suppose 
 there would be no problem with camping ?

 and speed: normally it's all very fast, but sometimes, it takes a little bit 
 (3 or more seconds) to respond camping, and I'm not doing nothing serious at 
 all, just the example from pastie.

 is because I'm using the development mode instead of production, like in RoR ?

 thanks again !

 regards,

 r.



 On 18jun, 2010, at 12:33 , Magnus Holm wrote:

 Yeah, people always get a little confused because you don't need to
 define your database when you're using bin/camping (it has a default
 SQLite database at ~/.camping.db).

 I also see that there's some old, database code here; we definitely
 need to update our documentation (yes, I'm working on it!)

 First of all, the table name should be list_people (since people
 is the plural to person and the table names are always in
 lowercase), but you should rather do `create_table Person.table_name`
 and `drop_table Person.table_name` because then you don't need to
 think about it at all :-)

 Secondly, you only need this in order to create the database:

 def List.create
  List::Models.create_schema
 end

 Then it will use a SQLite database at ~/.camping.db (as long as you
 start it with `camping list.rb`). This is perfect for just testing
 things out (you can also run `camping -C list.rb` to get an IRB
 console). Please note that if you only run `camping list.rb`, you'll
 have to load the page in the browser before the migrations run.

 If you want to use a specific database, you can add this:

 def List.create
  List::Models::Base.establish_connection(
    :adapter = postgresql,
    :username = root,
    :password = toor,
    :database = list
  )
  List::Models.create_schema
 end

 Or you might want to add the information in a database.yml file:

 ---
 adapter: postgresql
 username: root
 password: toor
 database: list

 And then rather do:

 require 'yaml'

 def List.create
  List::Models::Base.establish_connection(YAML.load(File.read(database.yml)))
  List::Models.create_schema
 end

 Please note that if you connect to a database which already has the
 tables, DON'T run `List::Models.create_schema` as this will probably
 delete the whole database. General rule: you only need migrations to
 setup the database.

 --

 And thirdly: Yes, we are aware of that the migration support isn't
 very nice. In the future we hope to have something like:

 module List::Models
  class Person
    t.string :name
  end
 end

 def List.create
  List::Models.setup!
 end

 Until then, you'll have to stick with the current solution :-)


 // Magnus Holm



 On Fri, Jun 18, 2010 at 11:09, Raimon Fernandez co...@montx.com wrote:

 On 17jun, 2010, at 21:04 , Magnus Holm wrote:


 That's (hopefully) the simplest way to generate XML with Camping.

 You still need to create a model to store/retrieve the data. Before we
 can help you here, we need to know a few things: Is it going to fetch
 data from a specific place, or should it create its own database (from
 scratch)? Any 

Re: First time on Camping

2010-06-18 Thread Magnus Holm
Oh, and I also have the speed issue! That's definitely a bug. I'll
have a look at it later...

On Friday, June 18, 2010, Raimon Fernandez co...@montx.com wrote:
 buf, now I'm lost ...

 :-))

 no, really, thanks for that info, now I have working as I want ...

 :-)


 I've tested and created a new databse, and is working also.

 I've created a new sqlite3 from terminal and filled-up with some data and now 
 I can use this databse from Camping, cool!

 And, caping is serving the data with .xml format and I can get it from my 
 devices, cool!

 I'm going to play more with thise, sure I'll come back with more questions ...

 :-)

 ah, I always use Thin with Nginx for my RoR instead of Mongrel, I suppose 
 there would be no problem with camping ?

 and speed: normally it's all very fast, but sometimes, it takes a little bit 
 (3 or more seconds) to respond camping, and I'm not doing nothing serious at 
 all, just the example from pastie.

 is because I'm using the development mode instead of production, like in RoR ?

 thanks again !

 regards,

 r.



 On 18jun, 2010, at 12:33 , Magnus Holm wrote:

 Yeah, people always get a little confused because you don't need to
 define your database when you're using bin/camping (it has a default
 SQLite database at ~/.camping.db).

 I also see that there's some old, database code here; we definitely
 need to update our documentation (yes, I'm working on it!)

 First of all, the table name should be list_people (since people
 is the plural to person and the table names are always in
 lowercase), but you should rather do `create_table Person.table_name`
 and `drop_table Person.table_name` because then you don't need to
 think about it at all :-)

 Secondly, you only need this in order to create the database:

 def List.create
  List::Models.create_schema
 end

 Then it will use a SQLite database at ~/.camping.db (as long as you
 start it with `camping list.rb`). This is perfect for just testing
 things out (you can also run `camping -C list.rb` to get an IRB
 console). Please note that if you only run `camping list.rb`, you'll
 have to load the page in the browser before the migrations run.

 If you want to use a specific database, you can add this:

 def List.create
  List::Models::Base.establish_connection(
    :adapter = postgresql,
    :username = root,
    :password = toor,
    :database = list
  )
  List::Models.create_schema
 end

 Or you might want to add the information in a database.yml file:

 ---
 adapter: postgresql
 username: root
 password: toor
 database: list

 And then rather do:

 require 'yaml'

 def List.create
  List::Models::Base.establish_connection(YAML.load(File.read(database.yml)))
  List::Models.create_schema
 end

 Please note that if you connect to a database which already has the
 tables, DON'T run `List::Models.create_schema` as this will probably
 delete the whole database. General rule: you only need migrations to
 setup the database.

 --

 And thirdly: Yes, we are aware of that the migration support isn't
 very nice. In the future we hope to have something like:

 module List::Models
  class Person
    t.string :name
  end
 end

 def List.create
  List::Models.setup!
 end

 Until then, you'll have to stick with the current solution :-)


 // Magnus Holm



 On Fri, Jun 18, 2010 at 11:09, Raimon Fernandez co...@montx.com wrote:

 On 17jun, 2010, at 21:04 , Magnus Holm wrote:


 That's (hopefully) the simplest way to generate XML with Camping.

 You still need to create a model to store/retrieve the data. Before we
 can help you here, we need to know a few things: Is it going to fetch
 data from a specific place, or should it create its own database (from
 scratch)? Any specific database you want to use?

 Here's a Pastie with all the code: http://pastie.org/1008983 (Should
 work on any version of Camping).

 I'm trying to adapt your pastie to use a sqlite databse, but I'm having 
 some errors that I can't see ...

 Here's a Pastie with all code: http://pastie.org/1009797

 I'm just trying to create with code a simple table called Persons with some 
 fields but ...

 :-)

 Also,  I can't find where is creating the database ...

 thanks,

 regards,

 r.
 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
  http://rubyforge.org/mailman/listinfo/camping-list

-- 
// Magnus Holm
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Re: First time on Camping

2010-06-18 Thread Raimon Fernandez
Hi again,

I know this is more related to builder than to camping, but not sure where to 
ask for it ...

:-)


My app receives .xml file from some different sources, and all of them, except 
the camping one, are formatted like this:


?xml version=1.0 encoding=UTF-8?
person
  nameJim Fernández/name
  phone555-1234/phone
/person


but camping is formatting like this:

?xml version=1.0 encoding=UTF-8?
person
  nameJim Fern#225;ndez/name
  phone555-1234/phone
/person


The main difference is the encoding for some chars:

á = #225;

I can't find in builder how to write values without escaping them ...

thanks,

r.

On 17jun, 2010, at 21:04 , Magnus Holm wrote:

 And if you want this XML:
 
 ?xml version=1.0 encoding=UTF-8?
 posts
  post
titleHiya/title
contentHey/content
  /post
 /posts
 
 You have this view:
 
 module App::Views
  def posts(xml)
xml.posts do
  @posts.each do |post|
xml.post do
  xml.title(post.title)
  xml.content(post.content)
end
  end
end
  end
 end


___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-18 Thread Dave Everitt
Hmm - quickly: in similar setups this usually requires UTF-8 to be  
specified throughout Camping(?), the database, within your files (and  
any markup files they generate), and (sometimes) also on the server.  
Then you can just use/store/retrieve the characters as they are - Dave E



The main difference is the encoding for some chars:

á = #225;


___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-18 Thread Magnus Holm
This shouldn't be a problem, because that's the way to add non-ASCII
characters to XML documents. A proper XML parser should handle it...

// Magnus Holm (from my phone)

On Friday, June 18, 2010, Raimon Fernandez co...@montx.com wrote:
 Hi again,

 I know this is more related to builder than to camping, but not sure where to 
 ask for it ...

 :-)


 My app receives .xml file from some different sources, and all of them, 
 except the camping one, are formatted like this:


 ?xml version=1.0 encoding=UTF-8?
 person
   nameJim Fernández/name
   phone555-1234/phone
 /person


 but camping is formatting like this:

 ?xml version=1.0 encoding=UTF-8?
 person
   nameJim Fern#225;ndez/name
   phone555-1234/phone
 /person


 The main difference is the encoding for some chars:

 á = #225;

 I can't find in builder how to write values without escaping them ...

 thanks,

 r.

 On 17jun, 2010, at 21:04 , Magnus Holm wrote:

 And if you want this XML:

 ?xml version=1.0 encoding=UTF-8?
 posts
  post
    titleHiya/title
    contentHey/content
  /post
 /posts

 You have this view:

 module App::Views
  def posts(xml)
    xml.posts do
     �...@posts.each do |post|
        xml.post do
          xml.title(post.title)
          xml.content(post.content)
        end
      end
    end
  end
 end


 ___
 Camping-list mailing list
 Camping-list@rubyforge.org
 http://rubyforge.org/mailman/listinfo/camping-list


-- 
// Magnus Holm
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Re: First time on Camping

2010-06-17 Thread Magnus Holm
Hey Raimon,

I see that you've been experimenting with Camping and Reststop lately,
and just thought I should chime in a bit.

You definitely don't *need* Reststop in order to achieve what you
want, so it might be a good idea to just leave Reststop until it gets
a little more robust. Let's see how we can tackle your problem with
Camping only:

For serving XML, you can use Builder (http://builder.rubyforge.org/).
Here's a little helper for you:

require 'camping'
require 'builder'

Camping.goes :App

module App
  # We include the Views module so we can call them as methods.
  include Views

  module Helpers
def xml(name)
  # We'll need to send this as text/xml
  @headers[Content-Type] = text/xml
  result = String.new
  # The builder takes a `target` where the XML will end up
  builder = Builder::XmlMarkup.new(:target = result, :indent = 2)
  # Generates a ?xml version=1.0 encoding=UTF-8 ?
  builder.instruct!
  # Calls the method you sent in, passing in the builder as an argument
  send(name, builder)
  # Return the restult
  result
end
  end
end



If you for instance want to generate this XML:

posts
  post title=Post titleContent of post/post
/posts

You would have the following view:

module App::Views
  def posts(xml)
xml.posts do
  @posts.each do |post|
xml.post(post.content, :title = post.title)
  end
end
  end
end

And if you want this XML:

?xml version=1.0 encoding=UTF-8?
posts
  post
titleHiya/title
contentHey/content
  /post
/posts

You have this view:

module App::Views
  def posts(xml)
xml.posts do
  @posts.each do |post|
xml.post do
  xml.title(post.title)
  xml.content(post.content)
end
  end
end
  end
end

-

You render the XML in the controller like this:

module App::Controllers
  class Index
def get
  # The view has access to this variable
  @posts = Post.all
  # Calls the helper, which in turn calls the view
  xml :posts
end
  end
end



That's (hopefully) the simplest way to generate XML with Camping.

You still need to create a model to store/retrieve the data. Before we
can help you here, we need to know a few things: Is it going to fetch
data from a specific place, or should it create its own database (from
scratch)? Any specific database you want to use?

Here's a Pastie with all the code: http://pastie.org/1008983 (Should
work on any version of Camping).

// Magnus Holm



On Tue, Jun 8, 2010 at 08:25, Raimon Fernandez co...@montx.com wrote:
 hi list,


 This is my first time here, my first time reading seriously something about 
 Camping.

 I need to create a very simple web server for serving only .xml files, 
 extracted from a sqlite database with some queries.

 I'm quite comfortable with Ruby on Rails, but it would be too much for this 
 project, so I've decided to take a look at Camping or Sinatra, not sure 
 what's the best option.

 There would be only 5 tables, 100 rows per table, and the idea is fetch data 
 from a device like iPad/iPhone/iPod, update it and persist the changes in the 
 server. The data transfer would be in plain .xml files, no html or css.

 Any helpful directions would be great

 :-)

 thanks,

 r.
 ___
 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: First time on Camping

2010-06-17 Thread Matt Zukowski
Something's not right with your rubygems install maybe try `gem update
--system` first?

On Tue, Jun 8, 2010 at 3:33 PM, Raimon Fernandez co...@montx.com wrote:


 On 8jun, 2010, at 21:18 , David Susco wrote:

  Is the hoe gem installed?

 no, the same error as before:

 Last login: Tue Jun  8 18:43:33 on ttys002
 MacBook-ProII-2:~ montx$ sudo gem install hoe
 Password:
 ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: nodename nor servname provided, or not known (
 http://gems.rubyforge.org/gems/json_pure-1.4.3.gem)
 MacBook-ProII-2:~ montx$


 we have to wait ...

 thanks,

 r.

 
  Dave
 
  On Tue, Jun 8, 2010 at 1:01 PM, Raimon Fernandez co...@montx.com
 wrote:
 
  On 8jun, 2010, at 18:43 , David Susco wrote:
 
  I don't believe the gem has been updated to include Matt's or
  Philippe's latest changes. You could clone it from GitHub though and
  rake and install it yourself.
 
  I think it requieres 'hoe' and I can't install without rubygems working
 or once again, find where the repo is and start digging again ...
 
  :-)
 
  MacBook-ProII-2:reststop montx$ sudo rake Rakefile
  (in /Users/montx/Documents/Camping/reststop)
  rake aborted!
  no such file to load -- hoe
  /Users/montx/Documents/Camping/reststop/rakefile:10
 
 
  thanks!
 
  r.
  ___
  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

___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Re: First time on Camping

2010-06-08 Thread David Susco
Camping with reststop ought will make serving the xml files easy
enough. The example on github ought to get you started:

http://github.com/camping/reststop

Dave

On Tue, Jun 8, 2010 at 2:25 AM, Raimon Fernandez co...@montx.com wrote:
 hi list,


 This is my first time here, my first time reading seriously something about 
 Camping.

 I need to create a very simple web server for serving only .xml files, 
 extracted from a sqlite database with some queries.

 I'm quite comfortable with Ruby on Rails, but it would be too much for this 
 project, so I've decided to take a look at Camping or Sinatra, not sure 
 what's the best option.

 There would be only 5 tables, 100 rows per table, and the idea is fetch data 
 from a device like iPad/iPhone/iPod, update it and persist the changes in the 
 server. The data transfer would be in plain .xml files, no html or css.

 Any helpful directions would be great

 :-)

 thanks,

 r.
 ___
 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


Re: First time on Camping

2010-06-08 Thread Raimon Fernandez
Hi Dave,

On 8jun, 2010, at 17:04 , David Susco wrote:

 Camping with reststop ought will make serving the xml files easy
 enough. The example on github ought to get you started:
 
 http://github.com/camping/reststop

thanks !

reststop is also a gem for camping ?

regards,



r.



___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-08 Thread David Susco
I don't believe the gem has been updated to include Matt's or
Philippe's latest changes. You could clone it from GitHub though and
rake and install it yourself.

Dave

On Tue, Jun 8, 2010 at 11:55 AM, Raimon Fernandez co...@montx.com wrote:
 Hi Dave,

 On 8jun, 2010, at 17:04 , David Susco wrote:

 Camping with reststop ought will make serving the xml files easy
 enough. The example on github ought to get you started:

 http://github.com/camping/reststop

 thanks !

 reststop is also a gem for camping ?

 regards,



 r.



 ___
 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


Re: First time on Camping

2010-06-08 Thread Raimon Fernandez

On 8jun, 2010, at 18:43 , David Susco wrote:

 I don't believe the gem has been updated to include Matt's or
 Philippe's latest changes. You could clone it from GitHub though and
 rake and install it yourself.

I think it requieres 'hoe' and I can't install without rubygems working or once 
again, find where the repo is and start digging again ...

:-)

MacBook-ProII-2:reststop montx$ sudo rake Rakefile 
(in /Users/montx/Documents/Camping/reststop)
rake aborted!
no such file to load -- hoe
/Users/montx/Documents/Camping/reststop/rakefile:10


thanks!

r.
___
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list


Re: First time on Camping

2010-06-08 Thread David Susco
Is the hoe gem installed?

Dave

On Tue, Jun 8, 2010 at 1:01 PM, Raimon Fernandez co...@montx.com wrote:

 On 8jun, 2010, at 18:43 , David Susco wrote:

 I don't believe the gem has been updated to include Matt's or
 Philippe's latest changes. You could clone it from GitHub though and
 rake and install it yourself.

 I think it requieres 'hoe' and I can't install without rubygems working or 
 once again, find where the repo is and start digging again ...

 :-)

 MacBook-ProII-2:reststop montx$ sudo rake Rakefile
 (in /Users/montx/Documents/Camping/reststop)
 rake aborted!
 no such file to load -- hoe
 /Users/montx/Documents/Camping/reststop/rakefile:10


 thanks!

 r.
 ___
 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


Re: First time on Camping

2010-06-08 Thread Raimon Fernandez

On 8jun, 2010, at 21:18 , David Susco wrote:

 Is the hoe gem installed?

no, the same error as before:

Last login: Tue Jun  8 18:43:33 on ttys002
MacBook-ProII-2:~ montx$ sudo gem install hoe
Password:
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: nodename nor servname provided, or not known 
(http://gems.rubyforge.org/gems/json_pure-1.4.3.gem)
MacBook-ProII-2:~ montx$ 


we have to wait ...

thanks,

r.

 
 Dave
 
 On Tue, Jun 8, 2010 at 1:01 PM, Raimon Fernandez co...@montx.com wrote:
 
 On 8jun, 2010, at 18:43 , David Susco wrote:
 
 I don't believe the gem has been updated to include Matt's or
 Philippe's latest changes. You could clone it from GitHub though and
 rake and install it yourself.
 
 I think it requieres 'hoe' and I can't install without rubygems working or 
 once again, find where the repo is and start digging again ...
 
 :-)
 
 MacBook-ProII-2:reststop montx$ sudo rake Rakefile
 (in /Users/montx/Documents/Camping/reststop)
 rake aborted!
 no such file to load -- hoe
 /Users/montx/Documents/Camping/reststop/rakefile:10
 
 
 thanks!
 
 r.
 ___
 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