Language/Framework support for Interacting With CouchDB - database

I am interested in knowing if there are any server-side web application frameworks which integrate nicely with CouchDB? Does anyone have any experience in doing this? It seems like a dynamic language would be well-suited for playing with the JSON, but I am more interested in hearing about how it would fit in with the framework and the application's design.

Two frameworks that I would suggest for CouchDB are Ruby on Rails and Django. Both have a small file you can include that allows for easy interaction with CouchDB. For Ruby/Rails, this gives you the ability to write code that looks like this (code snippets yanked from here):
# Create the database
server = Couch::Server.new("localhost", "5984")
server.put("/foo/", "")
# Insert a new document into the database
doc = <<-JSON
{"type":"comment","body":"First Post!"}
JSON
server.put("/foo/document_id", doc)
# Get the document back later
res = server.get("/foo/document_id")
json = res.body
puts json
Python/Django lets you do the same with a relatively minimal amount of work (see here). Both of these aren't at the web framework level but they require a minimal amount of work to set up and are pretty easy to get going in Rails and Django. The Django approach still requires some packages to be installed so if you just can't do that for some reason the Rails approach is the way to go.
Another good how-to on Python on Django can be found here (also lifted from the CouchDB FAQ).

The only web framework that dedicates itself to CouchDB is currently CouchDBKit for Python.
Check out the official wiki page that lists how to get started in your language:
http://wiki.apache.org/couchdb/Basics
Pick the language and framework that suits you best and then use one of the light CouchDB libraries with it.
It seems that things are move quite quickly at the moment for CouchDB. I'm sure there will be more frameworks out there soon with CouchDB support. I'm currently looking into building one for PHP.

I have had good success with jcouchdb for Java and CouchApp for JavaScript and CouchDBKit with Python. All of these are actively developed, open source and well designed and easy to enhance if they are missing something you really need. I have submitted patches and feature enhancements for jcouchdb and couchapp both.

Actually, you don't really need such a framework. Instead, you can just write the whole web application in CouchDB. It allows you to generate HTML files, or any other XML derived format, and you can even use HTML-templates. I consider this a good choice, because JavaScript is a rich and flexible language. On the other hand you don't have the overkill of a connection between the database and your web application.
For more details, check out: http://books.couchdb.org/relax/design-documents/shows
There's also a related question: Using CouchDB to serve HTML

Depending on what you want to build CouchApp may be something to look at: It's specially designed for writing apps with CouchDB:
https://github.com/jchris/couchapp/wiki/manual

Related

Is it alright to write a software creates a roster for a restaurant with JAVA language?

I need some advice on the project im working for fun during the summer. Say im writing a software that helps creating the roster base on the availiabilities of the staffs. I need some advice on how to implement these items below:
A database that holds the infomation of the staffs (ie.
availiabilities, minimum hours, maximum hours).
The core of the software where the process of arranging staffs on a day base on the database.
A GUI that displays the final version of roster after step 2 above so it can be printed out by the manager.
Im thinking of using Java but not sure how i to implement and connect the database, the core and the GUI together? Can i do everything listed using Java?Can anyone please suggest me a solution or an article for this?
There are many different paths you could follow, depending on what your end goals are.
DO you want to learn Java or are you just trying to practice application development ? I am assuming you are interested in an application that runs on the web.
For me, the best choices are either Java or PHP, but this is largely based on my own experiences. Others might argue that Python or Ruby would be a better to start.
For a Java based solution, you would use: Java JSPs with HTML for the front end (Javascript and JQuery optional); Java (Servlets) for the middle tier; JDBC, JPA, Spring, and/or Hybernate to connect to the DB; MySQL is a good candidate for the DB, but there are other options.
For a PHP based solution, you would use: PHP, HTML for the frond end (Javascript and JQuery optional); PHP for the middle tier (there are frameworks you coulse here as well); PHP to connect to the DB; MySQL is a good candidate for the DB, but there are other options.
If you dont know either, I think PHP is easier to setup and run for beginners, and is the basis for many open source and commercial web applications (e.g., WordPress); but Java is used for most large scale applications.

Integrating markdown into angularjs?

I've started writing a simple app using AngularJS + NodeJS to learn more about the stack, and it appears that getting markdown to work is a bit tricky and not that well supported. I'm coming from a ruby background, and I used the redcarpet markdown library, which was pretty standard and straightforward.
I've come across the angular-markdown-directive:
Pros
Simple to setup
Uses ngSanitize to clean user-submitted markdown. This library is supported by the official Angular team.
Cons
It uses showdown under the hood, which seems to have died a while back, but small progress seems to be picking up with the new maintainer. However, it has quite a few outstanding bugs, two particular bug reports dating back to 2013 and 2014 are worrying:
(1) Underscores are apparently interpreted to be italicized (will create malformed links):
https://github.com/showdownjs/showdown/issues/96
(2) Security issue that allows XSS still not patched:
https://github.com/showdownjs/showdown/issues/57
I'm not sure if (2) will be an issue in my case, since ngSanitize may help.
There is another library called markdown-it, but this library handles markdown in Nodejs instead of Angular. But their examples doesn't say much about best security practices.
--
Are there any full examples on how markdown can be securely integrated into a Node/Angular app? angular-markdown-directive seems like a good fit but has some painful problems, and most other markdown libraries are either dying/dead or they gloss over security in a production environment.
I decided to use markdown-it. It's pretty flexible; it actually allows parsing from either server or the client so it's up to you how and where you'd like to parse the markdown.
For me, I've opted to save the markdown text in the database and then parse the markdown on the client, and it works very well.
As for security, markdown-it comes with some built-in security measures, which is very nice. There is also a separate security module that you can use with it that offers additional features.

How does a webapp save files to its server?

I'm building a webapp where one can develop documents within the web browser (e.g., something like Zoho's document tool, or Google Docs). In my case, I have a set of arrays that store different paragraphs and other pieces of information, along with parallel arrays that store metadata on the paragraphs themselves.
The entire webapp is written in jQuery and associated libraries / plugins.
Is there an elegant way for me to save this as a file on the server itself? So far, I've been recommended using a hidden form to POST the arrays to the server and store them in a NoSQL database of some sort... This feels a bit painful to me and I'm wondering if (1) there is a more elegant approach, or (2) there is a library / framework that automates some of the sending / POSTing / saving.
Thank you!
You would need to create services that live on the server itself. These services would be methods such as (just as a simple example)
SaveDocument(User, Document)
GetDocument(User, Document)
you would need to configure your web app to call these services and pass in the required parameters. Now as for how to do this, you could write the services in any number of languages (Java using JavaEE, C# using WCF to name a few, but you can also do this in python/ruby/etc) and then generate WSDL interfaces to the services that any number of other languages could call.
There are lots of resources available on the web that cover this, so pick a language you want to learn, or are already proficient in and google around on how to develop web services in that language.
Good luck!

Is it possible to create a database driven website with flash?

I am a newbie programmer and i dont yet have any idea of the WEB. I wish to start learning a technology that will allow me to build websites( database driven) i dont know which one to choose. I know some actionscript3 and flash.
Is it possible to create a database driven website using these alone? Or do i need to learn any other technology? If i do then what should i learn? I know j2se for the desktop and oracle SQL/MySQL
please show me a path. Also wanted to know if there is any technology like Wordpress for J2EE/flash
OK so i finally got the feeling that i need to learn PHP anyway along with css and javascript. So it is fine. Also another query. Which CMS should i consider? Wordpress or Joomla?
You can develop a database driven website using Flash, but only in the same sense that you can develop a database driven website using AJAX. That is, you can build the front-end using Flash/ActionScript but the back-end is built using other technologies. Just like working with JavaScript to develop a front-end, from ActionScript you would be communicating with Java or PHP or Python or something on the server using RESTful calls and then actually working with the database in the server-side scripts.
Honestly = this question is too broad and generic, and answers are easily found with some google searches.
That being said = of course you can build a data driven flash site. The one caveat here is that flash itself is fundamentally client-side technology, so we must rely on other remote tech to do the heavy data lifting. The options are profuse.
For example, a developer might create a front facing presentation in Flex, which is the streamlined, data-centric extension of pure flash. His database interactions are written in php, and these are constantly called upon to deliver content to the user.
So - what technologies to use? Whatever you know. And if you don't know, then learn the ones that are closest to what you know.
Finally, although I am a die-hard fan of flash, this type of project (you didn't specify what you had in mind) could be done with many different technologies. So - maybe flash is the right answer, but maybe javascript (ajax) could manage the same thing and do it without the need of plugins.
Yes you can develop database driven site in flash/action script but you still need and back-end technology i recommend you to check WebORB you can develop the back-end using Java, PHP, or .NET In addition you can use Flash Remoting technology Flash/Flex to communicate with a back-end
Flash can't be directly connected to database. You must use another technique which would be "mediator". I have developed Flash game with MySql database and PHP and I recommend you to use this combination. Here is visually presented this kind of communication: http://www.youtube.com/watch?v=gRi-oxjFfCU
yes, it is possible to crate database driven website with flash and action-script. You would get an XML file when you do action script in flash, so you can store nodes of that XML file into database(mysql). You can then create an Admin interface to manage your database contents, that would indirectly change your xml nodes. So basically you can edit the xml file and store it in the database.

Using Backbone.js offline

I'm evaluating Backbone.js for keeping data and UI synchronized in my web app. However, much of Backbone's value seems to lie in its use of RESTful interfaces. Though I may add server-side backup in the future, my primary use case involves storing all data offline using HTML5 local storage.
Is Backbone overkill for such a use case? If so, is there a better solution, focused solely on updating UI when data changes, and vice versa? (I'm also looking into Knockout and Javascript MVC.)
EDIT: I'm also now looking into Angular.js and jQuery Data Link.
Backbone.js works just as well with local storage as it does with RESTful queries.
I'm a learn-by-example kind of guy so here are some links to get you started:
Todos, a todo application
that uses local storage and
backbone.js, check out the annotated
source to see how it works.
The localStorage adapter is
all you need to get started, take a
look at the annotated source of
that too.
In the past weeks I have evaluated different solution for a scenario close to yours; being a project done in my personal free time and not being a good Javascript programmer, all I needed was something easy to learn to avoid starting from scratch.
Not surprisingly, I had the same candidate: Backbone.js, Javascript MVC and Knockout.js.
Backbone.js won:
I wasn't be required to follow conventions or replace what was already in place
I've easly hacked in its codebase to understand what wasn't clear from the documentation
I've successfully ignored a large amount of its features that was not interesting for me
It gave acceptable performance on busy pages
It works
Backbone.js is lightweight and relatively magic-free; you will probably use a small subset of its feature but it provieds a solid base to develop your solution.
I know it's been a while but you may want to check out backbone-offline project on github: https://github.com/Ask11/backbone.offline
You can also take a look at AFrameJS. I have created a bare-bones proof of concept note-taking app that works offline using HTML5 WebSQL spec, but also want to create an adapter that uses localStorage as well. My personal opinion (and I am biased) is that using an MVC library of any sorts is going to help you in the long run - the value of libraries such as Backbone, Knockout, and AFrame lie in their ability to reduce the cognitive load of the developer by enforcing a good separation of concerns. Data related functionality reside in models, displaying that data resides in Views, and the glue is kept in Controllers. Separating these three concepts might seem pedantic at first, but the end result is code that is easier to develop, easier to test, easier to maintain, and easier to reuse. A basic tutorial on using AFrameJS can be found on my site at: http://www.shanetomlinson.com/2011/aframejs-tutorial-for-noobs/

Resources