Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

public some notes

  • Loading branch information...
commit 3a320b52e24032848c33ecc64629c8c905208964 1 parent 3d6a0e2
Daniel authored
6  app/controllers/notes_controller.rb
... ...
@@ -1,4 +1,5 @@
1 1
 class NotesController < ApplicationController
  2
+  skip_before_filter :login_required, :only => [:show]
2 3
   # GET /notes
3 4
   # GET /notes.xml
4 5
   def index
@@ -14,6 +15,11 @@ def index
14 15
   # GET /notes/1.xml
15 16
   def show
16 17
     @note = Note.find(params[:id])
  18
+    @page_hader = "#{@note.user.login.upcase}'s"
  19
+    
  20
+    if !@note.public and !logged_in?
  21
+      return login_required
  22
+    end
17 23
 
18 24
     respond_to do |format|
19 25
       format.html # show.html.erb
16  app/views/layouts/application.html.erb
@@ -37,11 +37,16 @@
37 37
   <body>
38 38
     <div id="wrapper">
39 39
       <div id="ceiling">
40  
-        <b>
  40
+        <div style="float: right;">
41 41
           <% if logged_in? %>
42  
-            <%= current_user.login.upcase %>'s
  42
+            <%= link_to "Sign out", logout_path %>
  43
+          <% else %>
  44
+            <%= link_to "Sign in", login_path %>
43 45
           <% end %>
44  
-          Notepad
  46
+        </div>
  47
+        <b>
  48
+          <% @page_hader ||= logged_in? ? "#{current_user.login.upcase}'s " : "" %>
  49
+          <%= link_to "#{@page_hader} Notepad", root_path %>
45 50
         </b>
46 51
         <small>
47 52
           <i>Beta</i>
@@ -49,11 +54,6 @@
49 54
       </div>
50 55
 
51 56
       <div id="main">
52  
-        <div id="header">
53  
-          <h1>
54  
-            <%= link_to "Home", root_path %>
55  
-          </h1>
56  
-        </div>
57 57
         <%= yield %>
58 58
       </div>
59 59
 
4  app/views/notes/_form.html.erb
@@ -13,6 +13,10 @@
13 13
     <%= f.text_area :content, :style => "width: 96%;" %>
14 14
   </p>
15 15
   <p>
  16
+    <%= f.check_box :public %>
  17
+    <label>Public?</label>
  18
+  </p>
  19
+  <p>
16 20
     <%= f.hidden_field :parent_id %>
17 21
     <%= f.submit 'Save' %>
18 22
     <%= link_to "Cancel", "javascript: history.back();" %>
3  app/views/notes/_index.html.erb
@@ -20,6 +20,9 @@
20 20
             <%= "~" * note.children.count %>
21 21
             sub: <%= note.children.count %>
22 22
           <% end %>
  23
+          <% if note.public %>
  24
+            <b style="color: green;">Public</b>
  25
+          <% end %>
23 26
         </li>
24 27
       <% end %>
25 28
     </ul>
41  app/views/notes/show.html.erb
... ...
@@ -1,24 +1,31 @@
1 1
 
2 2
 <h1>
3 3
   <%= h @note.title %>
4  
-  <% if @note.shortcut %>
5  
-    <small style="color: green;">TOP</small>
  4
+  <% if logged_in? %>
  5
+    <% if @note.shortcut %>
  6
+      <small style="color: green;">TOP</small>
  7
+    <% end %>
  8
+    <% if @note.public %>
  9
+      <small style="color: green;">Public</small>
  10
+    <% end %>
6 11
   <% end %>
7 12
 </h1>
8 13
 
9  
-<small>
10  
-  Menus:
11  
-  <%= link_to "Edit", edit_note_path(@note) %> -
12  
-  <%= link_to "Remove", @note, :method => :delete, :confirm => "Are you sure?" %>
13  
-  <% if @note.shortcut %>
14  
-    - <%= link_to "Remove from Top", note_path(@note, :note=>{:shortcut => false}), :method => :put %>
15  
-  <% else %>
16  
-    - <%= link_to "Put at Top", note_path(@note, :note=>{:shortcut => true}), :method => :put %>
17  
-  <% end %>
18  
-  <% if @note.parent %>
19  
-    - Parent: <%= link_to h(@note.parent.title), @note.parent %>
20  
-  <% end %>
21  
-</small>
  14
+<% if logged_in? %>
  15
+  <small>
  16
+    Menus:
  17
+    <%= link_to "Edit", edit_note_path(@note) %> -
  18
+    <%= link_to "Remove", @note, :method => :delete, :confirm => "Are you sure?" %>
  19
+    <% if @note.shortcut %>
  20
+      - <%= link_to "Remove from Top", note_path(@note, :note=>{:shortcut => false}), :method => :put %>
  21
+    <% else %>
  22
+      - <%= link_to "Put at Top", note_path(@note, :note=>{:shortcut => true}), :method => :put %>
  23
+    <% end %>
  24
+    <% if @note.parent %>
  25
+      - Parent: <%= link_to h(@note.parent.title), @note.parent %>
  26
+    <% end %>
  27
+  </small>
  28
+<% end %>
22 29
 
23 30
 <div>
24 31
   <% if @note.content.blank? %>
@@ -31,6 +38,8 @@
31 38
 
32 39
 <h2>Sub Notes</h2>
33 40
 
34  
-<%= link_to "Add Sub Note", new_note_path(:parent_id => @note.id) %>
  41
+<% if logged_in? %>
  42
+  <%= link_to "Add Sub Note", new_note_path(:parent_id => @note.id) %>
  43
+<% end %>
35 44
 
36 45
 <%= render :partial => "notes/index", :locals => { :notes => @note.children } %>
9  db/migrate/20100104085708_add_public_to_note.rb
... ...
@@ -0,0 +1,9 @@
  1
+class AddPublicToNote < ActiveRecord::Migration
  2
+  def self.up
  3
+    add_column :notes, :public, :boolean, :default => false, :null => false
  4
+  end
  5
+
  6
+  def self.down
  7
+    remove_column :notes, :public
  8
+  end
  9
+end
7  public/stylesheets/layout.css
@@ -53,6 +53,9 @@ textarea{
53 53
 input[type=checkbox]{
54 54
     vertical-align: middle;
55 55
 }
  56
+#ceiling{
  57
+    margin-bottom: 4px;
  58
+}
56 59
 #ceiling, #floor{
57 60
     background: #000;
58 61
     color: #fff;
@@ -61,6 +64,10 @@ input[type=checkbox]{
61 64
 #ceiling i{
62 65
     color: #666;
63 66
 }
  67
+#ceiling a{
  68
+    color: #fff;
  69
+    text-decoration: none;
  70
+}
64 71
 #header{
65 72
     border-bottom:1px solid #000;
66 73
 }

0 notes on commit 3a320b5

Please sign in to comment.
Something went wrong with that request. Please try again.