Skip to content

Commit

Permalink
Updated files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Hwang committed Sep 17, 2011
1 parent dfba372 commit 747b5e0
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 44 deletions.
22 changes: 19 additions & 3 deletions _site/quick_start.html
Expand Up @@ -31,11 +31,13 @@ <h2>Quick start</h2>
<div class='note'> <div class='note'>
This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href='/admin_assistant/tutorial.html'>tutorial</a>. This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href='/admin_assistant/tutorial.html'>tutorial</a>.
</div> </div>
<p>1) Add the gem to your Gemfile, and install it with <code>bundle install</code>.</p> <h3 id='add_the_gem_to_your_gemfile'>Add the gem to your Gemfile</h3>


<pre><code>gem &#39;admin_assistant&#39;</code></pre> <pre><code>gem &#39;admin_assistant&#39;</code></pre>


<p>2) admin_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You&#8217;ll also need to make sure to include jquery, if you&#8217;re not including it already.</p> <h3 id='include_admin_assistants_css_and_javascript_in_your_layout'>Include admin_assistant&#8217;s CSS and Javascript in your layout</h3>

<p>admin_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You&#8217;ll also need to make sure to include jquery, if you&#8217;re not including it already.</p>


<pre><code>&lt;html&gt; <pre><code>&lt;html&gt;
&lt;head&gt; &lt;head&gt;
Expand All @@ -45,7 +47,21 @@ <h2>Quick start</h2>
... ...
&lt;/html&gt;</code></pre> &lt;/html&gt;</code></pre>


<p>3) Setup an admin controller by attaching it to a model and using the admin layout:</p> <p>If you&#8217;re using Sprockets, which is the default in Rails 3.1, you should include the CSS and Javascript assets in the manifest files that you use for your admin layout.</p>

<p>Javascript:</p>

<pre><code>//= require admin_assistant
//= require jquery.tokeninput.js</code></pre>

<p>CSS:</p>

<pre><code>//= require admin_assistant
//= require token-input</code></pre>

<h3 id='setup_an_admin_controller'>Setup an admin controller</h3>

<p>Use the admin layout, and call <code>admin_assistant_for</code> with the model class.</p>


<pre><code>class Admin::BlogPostsController &lt; ApplicationController <pre><code>class Admin::BlogPostsController &lt; ApplicationController
layout &#39;admin&#39; layout &#39;admin&#39;
Expand Down
56 changes: 48 additions & 8 deletions _site/tutorial.html
Expand Up @@ -31,20 +31,26 @@ <h2>Tutorial</h2>
<div class='note'> <div class='note'>
This document assumes you are a beginning Rails user; if you are familiar with Rails you might want to check out our <a href='/admin_assistant/quick_start.html'>quick start</a>. This document assumes you are a beginning Rails user; if you are familiar with Rails you might want to check out our <a href='/admin_assistant/quick_start.html'>quick start</a>.
</div> </div>
<p>1) Add the gem to <code>Gemfile</code> in the root of your Rails project.</p> <h3 id='add_the_gem_to_your_gemfile'>Add the gem to your Gemfile</h3>

<p>This is found at <code>Gemfile</code> in the root of your Rails project.</p>


<pre><code>gem &#39;admin_assistant&#39;</code></pre> <pre><code>gem &#39;admin_assistant&#39;</code></pre>


<p>2) Install the gem locally.</p> <h3 id='install_the_gem_locally'>Install the gem locally</h3>


<pre><code>$ bundle install</code></pre> <pre><code>$ bundle install</code></pre>


<p>3) admin_assistant uses jQuery. You may already have jQuery installed for your project, but if not, you can get it like so:</p> <h3 id='install_jquery_if_you_need_to'>Install jQuery if you need to</h3>

<p>admin_assistant uses jQuery. You may already have jQuery installed for your project (it&#8217;s the standard starting with Rails 3.1), but if not, you can get it like so:</p>


<pre><code>$ curl http://code.jquery.com/jquery-1.6.2.min.js &gt; \ <pre><code>$ curl http://code.jquery.com/jquery-1.6.2.min.js &gt; \
public/javascripts/jquery-1.6.2.min.js</code></pre> public/javascripts/jquery-1.6.2.min.js</code></pre>


<p>4) If you don&#8217;t have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called <code>app/views/layouts/admin.html.erb</code> like this:</p> <h3 id='create_a_separate_admin_layout_without_sprockets'>Create a separate admin layout (without Sprockets)</h3>

<p>If you don&#8217;t have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called <code>app/views/layouts/admin.html.erb</code> like this:</p>


<pre><code>&lt;html&gt; <pre><code>&lt;html&gt;
&lt;head&gt; &lt;head&gt;
Expand All @@ -58,21 +64,55 @@ <h2>Tutorial</h2>


<p>If you&#8217;ve already created an admin layout, you should add the javascript references, and the call to <code>admin_assistant_includes</code>. This includes the standard CSS and Javascript that are packed with admin_assistant.</p> <p>If you&#8217;ve already created an admin layout, you should add the javascript references, and the call to <code>admin_assistant_includes</code>. This includes the standard CSS and Javascript that are packed with admin_assistant.</p>


<p>5) Create your new admin controller for a pre-existing model. We&#8217;ll be using a BlogPost as an example but you should be able to use any model in your Rails app.</p> <h3 id='create_a_separate_admin_layout_with_sprockets'>Create a separate admin layout (with Sprockets)</h3>

<p>Rails 3.1 recommends Sprockets as the default asset packager. If you&#8217;re using Sprockets, you&#8217;ll probably want to create separate <code>admin.js</code> and <code>admin.css</code> manifest files. <code>app/views/layouts/admin.html.erb</code> will look like this:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;%= javascript_include_tag &quot;admin&quot; %&gt;
&lt;%= stylesheet_link_tag &quot;admin&quot; %&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%= yield %&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>

<p>And you will add admin_assistant&#8217;s assets to the manifest files, which you will most likely put at <code>app/assets/javascripts/admin.js</code> and <code>app/assets/stylesheets/admin.css</code>.</p>

<p>Javascript:</p>

<pre><code>//= require admin_assistant
//= require jquery.tokeninput.js</code></pre>

<p>CSS:</p>

<pre><code>//= require admin_assistant
//= require token-input</code></pre>

<h3 id='create_an_admin_controller'>Create an admin controller</h3>

<p>Create your new admin controller for a pre-existing model. We&#8217;ll be using a BlogPost as an example but you should be able to use any model in your Rails app.</p>


<pre><code>./script/generate controller admin/blog_posts</code></pre> <pre><code>./script/generate controller admin/blog_posts</code></pre>


<p>6) Open <code>app/controllers/admin/blog_posts_controller.rb</code> and set it up to use the admin layout and to use admin_assistant for the BlogPost model:</p> <h3 id='edit_your_admin_controller'>Edit your admin controller</h3>

<p>Open <code>app/controllers/admin/blog_posts_controller.rb</code> and set it up to use the admin layout and to use admin_assistant for the BlogPost model:</p>


<pre><code>class Admin::BlogPostsController &lt; ApplicationController <pre><code>class Admin::BlogPostsController &lt; ApplicationController
layout &#39;admin&#39; layout &#39;admin&#39;


admin_assistant_for BlogPost admin_assistant_for BlogPost
end</code></pre> end</code></pre>


<p>7) If you were already running your Rails app with <code>./script/server</code> etc, you should restart it.</p> <h3 id='restart_your_rails_app'>Restart your Rails app</h3>

<p>If you were already running your Rails app with <code>./script/server</code> etc, you should restart it.</p>

<h3 id='check_out_the_controller'>Check out the controller</h3>


<p>8) Visit <code>/admin/blog_posts</code> in your browser and you&#8217;ll see something like this:</p> <p>Visit <code>/admin/blog_posts</code> in your browser and you&#8217;ll see something like this:</p>


<p><img src='/admin_assistant/img/blog_posts-index.png' alt='index' /></p> <p><img src='/admin_assistant/img/blog_posts-index.png' alt='index' /></p>


Expand Down
23 changes: 20 additions & 3 deletions quick_start.markdown
Expand Up @@ -7,11 +7,13 @@ title: Quick start
This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href="/admin_assistant/tutorial.html">tutorial</a>. This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href="/admin_assistant/tutorial.html">tutorial</a>.
</div> </div>


1) Add the gem to your Gemfile, and install it with `bundle install`. ### Add the gem to your Gemfile


gem 'admin_assistant' gem 'admin_assistant'


2) admin\_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You'll also need to make sure to include jquery, if you're not including it already. ### Include admin\_assistant's CSS and Javascript in your layout

admin\_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You'll also need to make sure to include jquery, if you're not including it already.


<html> <html>
<head> <head>
Expand All @@ -20,8 +22,23 @@ This document assumes you are highly familiar with Ruby and Rails; if you are a
</head> </head>
... ...
</html> </html>

If you're using Sprockets, which is the default in Rails 3.1, you should include the CSS and Javascript assets in the manifest files that you use for your admin layout.


3) Setup an admin controller by attaching it to a model and using the admin layout: Javascript:

//= require admin_assistant
//= require jquery.tokeninput.js

CSS:

//= require admin_assistant
//= require token-input


### Setup an admin controller

Use the admin layout, and call `admin_assistant_for` with the model class.


class Admin::BlogPostsController < ApplicationController class Admin::BlogPostsController < ApplicationController
layout 'admin' layout 'admin'
Expand Down
14 changes: 6 additions & 8 deletions quick_start.markdown~
Expand Up @@ -7,23 +7,21 @@ title: Quick start
This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href="/admin_assistant/tutorial.html">tutorial</a>. This document assumes you are highly familiar with Ruby and Rails; if you are a beginning Rails user you might want to start with our <a href="/admin_assistant/tutorial.html">tutorial</a>.
</div> </div>


1) First, install the plugin from Github. 1) Add the gem to your Gemfile, and install it with `bundle install`.


./script/plugin install git://github.com/fhwang/admin_assistant.git gem 'admin_assistant'


2) If you don't have the popular will\_paginate gem, you'll need that too. See [http://wiki.github.com/mislav/will_paginate/installation](http://wiki.github.com/mislav/will_paginate/installation) for more info. 2) admin\_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You'll also need to make sure to include jquery, if you're not including it already.

3) admin\_assistant comes packaged with standard CSS and Javascript that you should include in whatever layout your admin controllers will be using. You'll also need to make sure to include prototype.js, effects.js, and controls.js, if you're not including them already.


<html> <html>
<head> <head>
<%= javascript_include_tag("prototype", "effects", "controls") %> <%= javascript_include_tag("jquery-1.6.2.min") %>
<%= admin_assistant_includes %> <%= admin_assistant_includes %>
</head> </head>
... ...
</html> </html>


4) Setup an admin controller by attaching it to a model and using the admin layout: 3) Setup an admin controller by attaching it to a model and using the admin layout:


class Admin::BlogPostsController < ApplicationController class Admin::BlogPostsController < ApplicationController
layout 'admin' layout 'admin'
Expand All @@ -42,5 +40,5 @@ Depending on the model you're using, you might notice a few things:
* There is no `destroy` action out of the box. This is intended as a safe default, but you can add it if you like. * There is no `destroy` action out of the box. This is intended as a safe default, but you can add it if you like.
* If you have more than 10 pages of a given model, the pagination at the bottom includes a jump form to let you automatically jump to a page you enter. * If you have more than 10 pages of a given model, the pagination at the bottom includes a jump form to let you automatically jump to a page you enter.


For more, check out the [API reference](./api/). For more, check out the [API reference](/admin_assistant/api/).


58 changes: 49 additions & 9 deletions tutorial.markdown
Expand Up @@ -7,20 +7,26 @@ title: Tutorial
This document assumes you are a beginning Rails user; if you are familiar with Rails you might want to check out our <a href="/admin_assistant/quick_start.html">quick start</a>. This document assumes you are a beginning Rails user; if you are familiar with Rails you might want to check out our <a href="/admin_assistant/quick_start.html">quick start</a>.
</div> </div>


1) Add the gem to `Gemfile` in the root of your Rails project. ### Add the gem to your Gemfile

This is found at `Gemfile` in the root of your Rails project.


gem 'admin_assistant' gem 'admin_assistant'


2) Install the gem locally. ### Install the gem locally


$ bundle install $ bundle install


3) admin\_assistant uses jQuery. You may already have jQuery installed for your project, but if not, you can get it like so: ### Install jQuery if you need to

admin\_assistant uses jQuery. You may already have jQuery installed for your project (it's the standard starting with Rails 3.1), but if not, you can get it like so:


$ curl http://code.jquery.com/jquery-1.6.2.min.js > \ $ curl http://code.jquery.com/jquery-1.6.2.min.js > \
public/javascripts/jquery-1.6.2.min.js public/javascripts/jquery-1.6.2.min.js


4) If you don't have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called `app/views/layouts/admin.html.erb` like this: ### Create a separate admin layout (without Sprockets)
If you don't have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called `app/views/layouts/admin.html.erb` like this:


<html> <html>
<head> <head>
Expand All @@ -33,22 +39,56 @@ This document assumes you are a beginning Rails user; if you are familiar with R
</html> </html>


If you've already created an admin layout, you should add the javascript references, and the call to `admin_assistant_includes`. This includes the standard CSS and Javascript that are packed with admin\_assistant. If you've already created an admin layout, you should add the javascript references, and the call to `admin_assistant_includes`. This includes the standard CSS and Javascript that are packed with admin\_assistant.


5) Create your new admin controller for a pre-existing model. We'll be using a BlogPost as an example but you should be able to use any model in your Rails app. ### Create a separate admin layout (with Sprockets)

Rails 3.1 recommends Sprockets as the default asset packager. If you're using Sprockets, you'll probably want to create separate `admin.js` and `admin.css` manifest files. `app/views/layouts/admin.html.erb` will look like this:

<html>
<head>
<%= javascript_include_tag "admin" %>
<%= stylesheet_link_tag "admin" %>
</head>
<body>
<%= yield %>
</body>
</html>

And you will add admin\_assistant's assets to the manifest files, which you will most likely put at `app/assets/javascripts/admin.js` and `app/assets/stylesheets/admin.css`.

Javascript:

//= require admin_assistant
//= require jquery.tokeninput.js

CSS:

//= require admin_assistant
//= require token-input

### Create an admin controller

Create your new admin controller for a pre-existing model. We'll be using a BlogPost as an example but you should be able to use any model in your Rails app.


./script/generate controller admin/blog_posts ./script/generate controller admin/blog_posts

### Edit your admin controller


6) Open `app/controllers/admin/blog_posts_controller.rb` and set it up to use the admin layout and to use admin\_assistant for the BlogPost model: Open `app/controllers/admin/blog_posts_controller.rb` and set it up to use the admin layout and to use admin\_assistant for the BlogPost model:


class Admin::BlogPostsController < ApplicationController class Admin::BlogPostsController < ApplicationController
layout 'admin' layout 'admin'


admin_assistant_for BlogPost admin_assistant_for BlogPost
end end


7) If you were already running your Rails app with `./script/server` etc, you should restart it. ### Restart your Rails app

If you were already running your Rails app with `./script/server` etc, you should restart it.

### Check out the controller


8) Visit `/admin/blog_posts` in your browser and you'll see something like this: Visit `/admin/blog_posts` in your browser and you'll see something like this:


![index](/admin_assistant/img/blog_posts-index.png) ![index](/admin_assistant/img/blog_posts-index.png)


Expand Down
35 changes: 22 additions & 13 deletions tutorial.markdown~
Expand Up @@ -3,45 +3,54 @@ layout: default
title: Tutorial title: Tutorial
--- ---


*This document assumes you are a beginning Rails user; if you are very familiar with Rails you might want to check out our [quick start](./quick_start.html).* <div class="note">
This document assumes you are a beginning Rails user; if you are familiar with Rails you might want to check out our <a href="/admin_assistant/quick_start.html">quick start</a>.
</div>


1) First, install the plugin from Github. 1) Add the gem to `Gemfile` in the root of your Rails project.


./script/plugin install git://github.com/fhwang/admin_assistant.git gem 'admin_assistant'

2) Install the gem locally.

$ bundle install

3) admin\_assistant uses jQuery. You may already have jQuery installed for your project, but if not, you can get it like so:


2) If you don't have the popular will\_paginate gem, you'll need that too. See [http://wiki.github.com/mislav/will_paginate/installation](http://wiki.github.com/mislav/will_paginate/installation) for more info. $ curl http://code.jquery.com/jquery-1.6.2.min.js > \
public/javascripts/jquery-1.6.2.min.js


3) If you don't have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called `app/views/layouts/admin.html.erb` like this: 4) If you don't have any admin controllers in your Rails project yet, you probably need to create a separate admin layout. Create a file called `app/views/layouts/admin.html.erb` like this:


<html> <html>
<head> <head>
<%= javascript_include_tag("prototype", "effects", "controls") %> <%= javascript_include_tag("jquery-1.6.2.min") %>
<%= admin_assistant_includes %> <%= admin_assistant_includes %>
</head> </head>
<body> <body>
<%=yield %> <%= yield %>
</body> </body>
</html> </html>


If you've already created an admin layout, you should add the javascript references, and the call to `admin_assistant_includes`. This includes the standard CSS and Javascript that are packed with admin\_assistant. If you've already created an admin layout, you should add the javascript references, and the call to `admin_assistant_includes`. This includes the standard CSS and Javascript that are packed with admin\_assistant.


4) Create your new admin controller for a pre-existing model. We'll be using a BlogPost as an example but you should be able to use any model in your Rails app. 5) Create your new admin controller for a pre-existing model. We'll be using a BlogPost as an example but you should be able to use any model in your Rails app.


./script/generate controller admin/blog_posts ./script/generate controller admin/blog_posts


5) Open `app/controllers/admin/blog_posts_controller.rb` and set it up to use the admin layout and to use admin\_assistant for the BlogPost model: 6) Open `app/controllers/admin/blog_posts_controller.rb` and set it up to use the admin layout and to use admin\_assistant for the BlogPost model:


class Admin::BlogPostsController < ApplicationController class Admin::BlogPostsController < ApplicationController
layout 'admin' layout 'admin'


admin_assistant_for BlogPost admin_assistant_for BlogPost
end end


6) If you were already running your Rails app with `./script/server` etc, you should restart it. 7) If you were already running your Rails app with `./script/server` etc, you should restart it.


7) Visit `/admin/blog_posts` in your browser and you'll see something like this: 8) Visit `/admin/blog_posts` in your browser and you'll see something like this:


![index](./img/blog_posts-index.png) ![index](/admin_assistant/img/blog_posts-index.png)


You can now search, paginate, create, and edit blog posts. You can now search, paginate, create, and edit blog posts.


Expand All @@ -52,5 +61,5 @@ Depending on the model you're using, you might notice a few things:
* There is no `destroy` action out of the box. This is intended as a safe default, but you can add it if you like. * There is no `destroy` action out of the box. This is intended as a safe default, but you can add it if you like.
* If you have more than 10 pages of a given model, the pagination at the bottom includes a jump form to let you automatically jump to a page you enter. * If you have more than 10 pages of a given model, the pagination at the bottom includes a jump form to let you automatically jump to a page you enter.


For more, check out the [API reference](./api/). For more, check out the [API reference](/admin_assistant/api/).


0 comments on commit 747b5e0

Please sign in to comment.