Permalink
Browse files

new readme and genre system

  • Loading branch information...
1 parent d79a9fb commit 594152b10cdedddb0f6e0cbbd92c07848393285c @eirworks committed Feb 10, 2012
View
10 README.md
@@ -0,0 +1,10 @@
+# Ranobe
+
+## Overview
+Ranobe is a japanese slang for Light Novel. Ranobe is rails app that powered engine behind Fiksimu site. It is a place where user can publish their own original stories and literatures.
+
+To be clear, this site is not only for light novel. One chapter short story also can be published in here.
+
+## Behind the Scene
+* Rails 3.0.10
+
View
4 app/models/genre.rb
@@ -0,0 +1,4 @@
+class Genre < ActiveRecord::Base
+ has_many :genretations
+ has_many :stories, through: :genretations
+end
View
4 app/models/genretation.rb
@@ -0,0 +1,4 @@
+class Genretation < ActiveRecord::Base
+ belongs_to :story
+ belongs_to :genre
+end
View
3 app/models/story.rb
@@ -1,5 +1,8 @@
class Story < ActiveRecord::Base
has_many :chapters
+ has_many :genretations
+ has_many :genres, through: :genretations
+
validates :title, :summary, :presence => {:message => 'Judul dan ringkasan cerita harus ada'}
before_save :check_url
View
3 app/stylesheets/screen.scss
@@ -32,8 +32,9 @@ header {
@include column(6);
font: {
size:1.9em;
- weight:bold;
+ //weight:bold;
style:italic;
+ family:georgia,times,serif;
}
color:$theme;
a {
View
6 app/views/stories/_form.html.haml
@@ -21,6 +21,12 @@
%br/
%span.form-meta
Dikosongi aja nggak apa-apa kok
+ %p
+ = hidden_field_tag 'story[genre_ids][]', nil
+ - g = Genre.all
+ - g.each do |genre|
+ = label_tag dom_id(genre), genre.name
+ = check_box_tag 'story[genre_ids][]', genre.id, @story.genre_ids.include?(genre.id), id: dom_id(genre)
%p.actions
= f.submit 'Save'
= link_to 'batal', my_stories_path
View
11 app/views/stories/show.html.haml
@@ -2,6 +2,9 @@
= link_to 'Kembali', my_stories_path
\|
= link_to 'Edit', edit_story_path(@story)
+ - if @chapters.length > 0 && @story.published == false
+ \|
+ = link_to( 'Publikasikan', publish_story_path, :method => 'post', :confirm => "Yakin? Sekali dipublikasikan tidak dapat di-non-publikasikan lagi")
- if @story.published
\|
= link_to 'Baca', root_url
@@ -11,6 +14,14 @@
= @story.title
%p
= @story.summary
+ %br/
+ %strong Genre:
+ - c = 1
+ %small
+ - @story.genres.each do |genre|
+ = (c == @story.genres.length ? 'dan' : '')
+ = link_to(genre.name,genre_path(genre.url)) + (c == @story.genres.length ? '' : ',')
+ - c += 1
%hr/
%h3 Bab
View
3 config/routes.rb
@@ -5,11 +5,14 @@
get "library/genres"
+ get 'perpus/genre(/:url)' => 'library#genres', :as => :genre
+
get 'ceritaku' => 'stories#index', :as => :my_stories
get 'cerita/buat' => 'stories#new', :as => :new_story
get 'cerita/:id' => 'stories#show', :as => :show_story
get 'cerita/:id/edit' => 'stories#edit', :as => :edit_story
delete 'cerita/:id' => 'stories#destroy', :as => :destroy_story
+ post 'cerita/:id/pub' => 'stories#publish', :as => :publish_story
get 'cerita/:id/bab_baru' => 'chapters#new', :as => :new_chapter
get 'cerita/:id/edit_bab/:chapter_id' => 'chapters#edit', :as => :edit_chapter
View
15 db/migrate/20120210040641_create_genres.rb
@@ -0,0 +1,15 @@
+class CreateGenres < ActiveRecord::Migration
+ def self.up
+ create_table :genres do |t|
+ t.string :name
+ t.text :description
+ t.string :url
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :genres
+ end
+end
View
14 db/migrate/20120210064532_create_genretations.rb
@@ -0,0 +1,14 @@
+class CreateGenretations < ActiveRecord::Migration
+ def self.up
+ create_table :genretations do |t|
+ t.integer :story_id
+ t.integer :genre_id
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :genretations
+ end
+end
View
17 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120209150545) do
+ActiveRecord::Schema.define(:version => 20120210064532) do
create_table "chapters", :force => true do |t|
t.string "title"
@@ -24,6 +24,21 @@
t.boolean "published", :default => false
end
+ create_table "genres", :force => true do |t|
+ t.string "name"
+ t.text "description"
+ t.string "url"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "genretations", :force => true do |t|
+ t.integer "story_id"
+ t.integer "genre_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "stories", :force => true do |t|
t.string "title"
t.text "summary"
View
27 db/seeds.rb
@@ -7,4 +7,29 @@
# Mayor.create(:name => 'Daley', :city => cities.first)
@story = Story.new(:title => "Momochan",:summary => "Dalam perjalanan pulang dari Pulau Iblis, Momotaro bertemu dengan seorang yang juga lahir dari buah persik.")
@story.save
-@chapter = Chapter.new(:title => "Momotaro",:content_md => "Momotaro adalah pahlawan dari Negeri Jepang. Ia mengalahkan semua Iblis di Pulau Iblis.",:story_id => @story.id).save
+@chapter = Chapter.new(:title => "Momotaro",:content_md => "Momotaro adalah pahlawan dari Negeri Jepang. Ia mengalahkan semua Iblis di Pulau Iblis.",:story_id => @story.id).save
+
+genres = [
+ ['Umum','Kehidupan sehari-hari'],
+ ['Dongeng','Kisah fantasi untuk anak-anak'],
+ ['Fantasi','Kisah berisi makhluk, tempat, dan segala hal fantasi'],
+ ['Horor','Cerita yang menyeramkan'],
+ ['Komedi','Cerita lucu dan menghibur'],
+ ['Misteri','Detektif,Pembunuhan,Puzzle saling melengkapi genre ini.'],
+ ['Fiksi Ilmiah','Kisah fantasi yang dipadukan dengan ilmu pengetahuan'],
+ ['Aksi','Penuh aksi laga'],
+ ['Light Novel','Novel yang ringkas dan mudah dipahami'],
+ ['Romansa','Kisah cinta sudah ada sejak Adam dan Hawa'],
+ ['Tragedi','Kisah yang menyayat hati. Matinya seorang karakter di cerita.'],
+ ['Supranatural','Kekuatan super, vampir, dan sihir.'],
+ ['Petualangan','Mencari harta karun, mengarungi 7 samudra, dan menjelajahi isi galaksi?'],
+ ['Drama','Kisah yang menguras airmata'],
+ ['Historik','Mendengarkan kisah dari masa lalu'],
+ ['Psikologikal','Dapat membuat otak kita meleleh. Sulit dicerna.'],
+ ['Sekolah','Kehidupan sekolah dan kuliah akan kita kenang selamanya'],
+ ['Olah Raga','Adu otot, tapi benar-benar menyehatkan']
+]
+
+genres.each do |genre|
+ Genre.new(:name => genre[0],:description => genre[1], :url => genre[0].downcase.gsub(/^[a-zA-Z0-9\s\-\_]$/i,'').gsub(/[\s\-\_]/,'_')).save
+end
View
3 public/javascripts/application.js
@@ -1,2 +1,5 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
+$(document).ready(function(){
+
+});
View
40 public/stylesheets/screen.css
@@ -525,19 +525,19 @@ header .site-title {
margin-right: 10px;
width: 230px;
font-size: 1.9em;
- font-weight: bold;
font-style: italic;
+ font-family: georgia,times,serif;
color: #336600;
}
/* line 147, ../../../../../../usr/local/lib/ruby/gems/1.9.1/gems/compass-0.11.7/frameworks/blueprint/stylesheets/blueprint/_grid.scss */
* html header .site-title {
overflow-x: hidden;
}
-/* line 40, ../../app/stylesheets/screen.scss */
+/* line 41, ../../app/stylesheets/screen.scss */
header .site-title a, header .site-title a:hover, header .site-title a:focus, header .site-title a:visited, header .site-title a:active {
text-decoration: none;
}
-/* line 45, ../../app/stylesheets/screen.scss */
+/* line 46, ../../app/stylesheets/screen.scss */
header .site-nav {
display: inline;
float: left;
@@ -549,85 +549,85 @@ header .site-nav {
* html header .site-nav {
overflow-x: hidden;
}
-/* line 48, ../../app/stylesheets/screen.scss */
+/* line 49, ../../app/stylesheets/screen.scss */
header .site-nav nav {
text-align: right;
}
-/* line 50, ../../app/stylesheets/screen.scss */
+/* line 51, ../../app/stylesheets/screen.scss */
header .site-nav nav a {
padding-left: 10px;
}
-/* line 56, ../../app/stylesheets/screen.scss */
+/* line 57, ../../app/stylesheets/screen.scss */
.content {
min-height: 450px;
}
-/* line 59, ../../app/stylesheets/screen.scss */
+/* line 60, ../../app/stylesheets/screen.scss */
footer {
margin-top: 1em;
border-top: 1px solid #336600;
font-size: .9em;
}
-/* line 67, ../../app/stylesheets/screen.scss */
+/* line 68, ../../app/stylesheets/screen.scss */
ul.list.stories {
border-top: 1px solid #ccc;
}
-/* line 69, ../../app/stylesheets/screen.scss */
+/* line 70, ../../app/stylesheets/screen.scss */
ul.list.stories li {
border-bottom: 1px solid #ccc;
padding: 10px 0;
}
-/* line 76, ../../app/stylesheets/screen.scss */
+/* line 77, ../../app/stylesheets/screen.scss */
ul.list.stories li .story-title {
font-weight: bold;
}
-/* line 88, ../../app/stylesheets/screen.scss */
+/* line 89, ../../app/stylesheets/screen.scss */
ul.list.chapters {
border-top: 1px solid #ccc;
}
-/* line 90, ../../app/stylesheets/screen.scss */
+/* line 91, ../../app/stylesheets/screen.scss */
ul.list.chapters li {
border-bottom: 1px solid #ccc;
padding: 4px 0;
}
-/* line 100, ../../app/stylesheets/screen.scss */
+/* line 101, ../../app/stylesheets/screen.scss */
ul.list li .meta-options {
display: none;
}
-/* line 104, ../../app/stylesheets/screen.scss */
+/* line 105, ../../app/stylesheets/screen.scss */
ul.list li:hover .meta-options {
display: inline;
}
-/* line 111, ../../app/stylesheets/screen.scss */
+/* line 112, ../../app/stylesheets/screen.scss */
.field_with_errors input, .field_with_errors textarea {
border-color: red;
}
-/* line 115, ../../app/stylesheets/screen.scss */
+/* line 116, ../../app/stylesheets/screen.scss */
.notification {
text-align: center;
color: #fff;
cursor: pointer;
}
-/* line 119, ../../app/stylesheets/screen.scss */
+/* line 120, ../../app/stylesheets/screen.scss */
.notification .error {
background-color: red;
}
-/* line 122, ../../app/stylesheets/screen.scss */
+/* line 123, ../../app/stylesheets/screen.scss */
.notification .notice {
color: #333;
background-color: #f7d708;
}
-/* line 126, ../../app/stylesheets/screen.scss */
+/* line 127, ../../app/stylesheets/screen.scss */
.notification .success {
background-color: darkgreen;
}
-/* line 129, ../../app/stylesheets/screen.scss */
+/* line 130, ../../app/stylesheets/screen.scss */
.notification .error, .notification .notice, .notification .success {
padding: 5px 0;
border-bottom: 1px solid #ccc;
View
9 test/fixtures/genres.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ name: MyString
+ description: MyText
+
+two:
+ name: MyString
+ description: MyText
View
11 test/fixtures/genretations.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
View
8 test/unit/genre_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class GenreTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
8 test/unit/genretation_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class GenretationTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end

0 comments on commit 594152b

Please sign in to comment.