Creating a wiki blog. Run apps that come with instant rails distribution select I /rails applications/open ruby console window Cd to cookbook or typo.

Slides:



Advertisements
Similar presentations
WordPress Installation for Beginners Sheila Bergman
Advertisements

Installing Instant WordPress 1)Download Instant WordPress from the following location:- 2) Double Click on the downloaded.
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
4.01 How Web Pages Work.
MMDE5011 – INTERACTIVE MEDIA PRACTICE 1 WEEK 1: INTRODUCTION TO HTML5
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
Trestle Generator Industrial-strength scaffolding for Ruby on Rails web application development.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Ruby on Rails CSE 190M, Spring 2009 Week 7. Customizing Our Views In our blog example, our entries were ordered from oldest to newest We can order them.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Project Implementation for COSC 5050 Distributed Database Applications Lab6.
A complete ror application. Some easy tutorials This uses oracle but it is easy to replace that with mysql:
Introductory CMS Training Welcome to the new Montana State University Content Management System!
Ruby on Rails CSE 190M, Spring 2009 Week 5. Installing Rails First, install Ruby with RubyGems Then, install the Rails gem gem install rails -version=2.3.2.
Ruby on Rails Creating a Rails Application Carol E Wolf CS396X.
Ruby on Rails (Slides modified by ements-2ed.shtml)
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
Creating a Web Page HTML, FrontPage, Word, Composer.
Web Development 311 Fall : Fall Why web pages? Most companies have intranets, extranets, and web sites Content can be changed quickly and.
Ruby on Rails: An Introduction JA-SIG Summer Conference 2007 Michael Irion The University of Tulsa.
A guide for UICET for using Wikispaces.  A wiki is a web page or collection of web pages that can be linked together as a website.  Wikis are often.
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
1 Dr Alexiei Dingli Web Science Stream Models, Views and Controllers.
UC Berkeley Hello Rails. Review: MVC Goal: separate organization of data (model) from UI & presentation (view) by introducing controller –mediates user.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
INTRODUCTION TO DREAMWEAVER 8. What we already know…  Design basics  Contrast  Repetition  Alignment  Repetition  HTML.
1 Dr Alexiei Dingli Web Science Stream Helpers, Forms and Layouts.
PUBLISHING ONLINE Chapter 2. Overview Blogs and wikis are two Web 2.0 tools that allow users to publish content online Blogs function as online journals.
MVC & ActiveRecord by Christian Mohr & Mohamed Souiai.
1 Dr Alexiei Dingli Web Science Stream Advanced ROR.
Ruby on Rails Your first app. Rails files app/ Contains the controllers, models, views and assets for your application. You’ll focus on this folder for.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
Ruby on Rails CSE 190M, Spring 2009 Week 6. Overview How to use a database Demo creating a blog application on Rails Explain how the application works.
© Copyright IBM Corporation 2007 AP/Americas April 15-18, 2007 Anaheim, California Introduction to RubyOnRails - a J2EE replacement? Russell Scheerer –
Ruby on Rails (Slides modified by ements-2ed.shtml)
Associations INFO 2310: Topics in Web Design and Programming.
1 Dr Alexiei Dingli Web Science Stream A ROR Blog.
Chapter 15 © 2009 by Addison Wesley Longman, Inc Overview of Rails - Rails is a development framework for Web-based applications - Rails is written.
Photo Gallery INFO 2310: Topics in Web Design and Programming.
Ruby on Rails: Databases. Rails Database Familiar Table Concept Naming convention – lower case, plural (i.e. tweets) How to Access (find), Update, Delete.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Blogging With WordPress Department of Information Science & Engineering Gogte Institute of Technology, Belgaum.
Chapter 15 © 2013 by Pearson Overview of Rails - Rails is a development framework for Web-based applications - Based on MVC architecture for applications.
Table of Contents TopicSlide Administrator Login 2 Administrator Navigations 3 Managing AlternativeDr.com Blogs 4 Managing Dr. Lloyd May Blogs 5 Managing.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Introduction to Ruby&Rails Yuri Veremeyenko Monica Verma.
1 Dr Alexiei Dingli Web Science Stream Installing ROR.
Transportation Agenda 165. Transportation About Pages Pages organize and present information Pages are files that end in.aspx 166.
Rails and routing INFO 2310: Topics in Web Design and Programming.
CS 160 and CMPE/SE 131 Software Engineering February 9 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Migrations Carol Wolf CS 396X. ISBNTitleAuthorImage EmmaAustenemma.jpg Oliver TwistDickenstwist.jpg HamletShakespearehamlet.jpg.
CSU Extension Webpage Template Session 4 February 2010.
Web 2.0 is the second generation of Internet-based services that emphasize online collaboration and sharing among users.
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
Advanced Migration By Aye Mon Tun.  To change database schema in consistent and easy way  In ruby code Migration? 11/25/2013 2Web Application Engineering.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
Melbourne LUG Presentation Learning Rails and Ruby - making webapps easier.
4.01 How Web Pages Work.
Intro to WordPress (Using XAMPP)
4.01 How Web Pages Work.
Oracle Application Express (APEX)
BASIC PHP and MYSQL Edward S. Flores.
4.01 How Web Pages Work.
Presentation transcript:

Creating a wiki blog

Run apps that come with instant rails distribution select I /rails applications/open ruby console window Cd to cookbook or typo or one of the apps that come with the distribution Run ruby script/server Go to localhost:3000/….

What is a wiki blog? What is a wiki? A wiki is a page or collection of Web pages designed to enable anyone who accesses it to contribute or modify content, using a simplified markup. What is a blog? A blog (a contraction of the term weblog) is a type of website, usually maintained by an individual with regular entries of commentary, descriptions of events, or other material such as graphics or video. Entries are commonly displayed in reverse-chronological order. "Blog" can also be used as a verb, meaning to maintain or add content to a blog.contractionwebsite How about combining these?

elements We will need a mysql table with information on wiki pages and postings. We will need to store names, dates created and dates updated for postings and pages. We will need a (wiki) column for slugs, since these can be referenced by other entries.

The tables in blog_development

posts table

wiki_page table

About the database As you’ll see, rake files in the db directory can be created to build the database tables. You could also create the database using phpmyadmin.

the wiki blog

Directory structure is pretty big compared to other projects

Listing all posts to the blog

Listing the pages (shows slug)

Adding a wiki page: use [] to link to a slug defined elsewhere

After adding a new wiki page

A new posting

The posting has links to slugs defined elsewhere

Create your rails app Remember to use the instant rails icon to start servers, and to select I /rails applications/open ruby console window in order to run these “dos” commands! In Rails_Apps: rails blog This will create a Rails application that uses a SQLite database for data storage. If you prefer to use MySQL, run this command instead: rails blog -d mysql (You may not need to do the mysql part, and you’ll need to check your database yml file in any case)

I used google wiki column plug-in for ruby which requires red cloth gem Wiki column link information is at You need to install redcloth. Their site is at To get Red Cloth gem, in DOS use ruby gem install Red Cloth The plugin wiki_column…in your blog DOS window: ruby script/plugin install

Work from the blog folder After you create the blog application, switch to its folder to continue work directly in that application: cd blog

config/database.yml for MySQL development: adapter: mysql database: blog_development username: root password: host: localhost # Warning: The database defined as 'test' will be erased and # re-generated from your development database when you run 'rake'. # Do not set this db to the same as development or production. test: adapter: mysql database: blog_test username: root password: host: localhost production: adapter: mysql database: blog_production username: root password: host: localhost

Create the db from RoR To create the database, in DOS in your RoR directory: rake db:create Or you can go to the Instant Rails menu and select configure/database using phpmyadmin and create the blog_development database that way. It must be called blog_development if your rails app is called blog! Next create controllers for home and index: ruby script/generate controller home index

Create a home controller blog>ruby script/generate controller home index The file app/views/home/index.html.erb contains one line: Hello, Rails! You may change this to some other welcome message html if you like

Now run the server ruby script/server will run the default server (webrick or mongrel) at localhost:3000. Navigate to This will show the default rails page. The set your own page delete public/index.html

Config routes Now, you have to tell Rails where your actual home page is located. Open the file config/routes.rb in your editor. This is your application's, routing file, which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. At the bottom of the file you'll see the default routes: map.connect ':controller/:action/:id'map.connect ':controller/:action/:id.:format' The default routes handle simple requests such as /home/index: Rails translates that into a call to the index action in the home controller. As another example, /posts/edit/1 would run the edit action in the posts controller with an id of 1. To hook up your home page, you need to add another line to the routing file, above the default routes: map.root :controller => "home" Now navigating to localhost:3000 will show your home index view.

scaffolding While scaffolding will get you up and running quickly, the "one size fits all" code that it generates is unlikely to be a perfect fit for your application. In most cases, you'll need to customize the generated code. Many experienced Rails developers avoid scaffolding entirely, preferring to write all or most of their source code from scratch. In particular, code for show, edit, delete, new methods are generated.

Using scaffolding to generate two models ruby script/generate scaffold WikiPage slug:string body:text created_at:datetime updated_at:datetime ruby script/generate scaffold Post name:string title:string content:text created_at:datetime updated_at:datetime Don't forget to migrate. rake db:migrate This will generate db tables for WikiPage and Post Note: We will “wikify” the content part of the post.

Your db/migrate/create_posts.rb will look a little like this class CreatePosts <ActiveRecord::Migration def self.up create_table :posts do |t| t.string :name t.string :title t.text :content t.timestamps end def self.down drop_table :posts End end

Adding a Link To hook the posts up to the home page you've already created, you can add a link to the home page. Open /app/views/home/index.html.erb and modify it as follows: Hello, Rails! To create similar links on other index, new, show, etc pages, cut and paste the links you want.

wikifying Add the following lines to the wikipage model: validates_uniqueness_of :slug wiki_column :body And to the Post model: wiki_column :content

In WikiPage show.rhtml Change the line to So app/views/wiki_page/show.rhtml has some code like: Body:

Do the same in post Fix app/views/posts/show.rhtml so it has code like Content:

in routes.rb file add a new resource to the routes.rb file map.resources :wiki, :controller => 'wiki_pages'

Using slugs Define unique slug names for your wiki pages and provide body for them which consists of a URL. Refer to wiki pages in post content with [slugname] You can go to Textile and get more information on syntax.

Add validation to the Post In app/models/post.rb: class Post 5 wiki_column :content end

Using Partials to Eliminate View Duplication As you saw earlier, the scaffold-generated views for the new and edit actions are largely identical. You can pull the shared code out into a partial template. This requires editing the new and edit views, and adding a new template. The new _form.html.erb template should be saved in the same app/views/posts folder as the files from which it is being extracted:

New files & partial new.html.erb: New post "form" %> edit.html.erb: Editing post "form" %> | _form.html.erb:

You can use a filter & a function to reduce redundancy class PostsController < ApplicationController before_filter :find_post, :only => [:show, :edit, :update, :destroy] #... def show #... end def edit end def update #... end def destroy #... end private def = Post.find(params[:id]) end end