Permalink
Browse files

init

  • Loading branch information...
0 parents commit 32e2274348b500dcd1fce9d755c1e5abcaee37b4 cloudhead committed Apr 15, 2009
Showing with 719 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +16 −0 bin/melon
  3. 0 bin/public/blah
  4. +5 −0 document.rb
  5. +19 −0 melon.gemspec
  6. +64 −0 melon.rb
  7. +9 −0 melon.ru
  8. +268 −0 melon.tmproj
  9. +27 −0 modules/base/controller.rb
  10. +84 −0 modules/base/model.rb
  11. +17 −0 modules/comments.rb
  12. +9 −0 modules/error.rb
  13. +18 −0 modules/posts.rb
  14. +90 −0 modules/session.rb
  15. +46 −0 public/js/melon.js
  16. +43 −0 router.rb
@@ -0,0 +1,4 @@
+public/images/*
+public/html/*
+public/json/*
+public/css/*
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+require 'fileutils'
+
+PUBLIC_DIR = 'public'
+CSS_DIR = 'css'
+HTML_DIR = 'html'
+IMAGES_DIR = 'images'
+JS_DIR = 'js'
+JSON_DIR = 'json'
+
+# Generate directory structure
+Dir.mkdir( PUBLIC_DIR ) unless File.exists? PUBLIC_DIR
+Dir.chdir( PUBLIC_DIR ) do
+ FileUtils.mkpath( CSS_DIR, HTML_DIR, IMAGES_DIR, JS_DIR, JSON_DIR )
+end
+
No changes.
@@ -0,0 +1,5 @@
+module Melon
+ class Document < Hash
+
+ end
+end
@@ -0,0 +1,19 @@
+Gem::Specification.new do |s|
+ s.name = "melon"
+ s.version = "0.1"
+ s.date = Time.today.strftime("%Y-%m-%d")
+ s.authors = ["cloudhead"]
+ s.email = "biopunk@gmail.com"
+ s.summary = "json blog engine"
+ s.homepage = "http://github.com/cloudhead/melon"
+ s.description = "minimal blog engine"
+ s.files = [ "README", "bin/prose", "lib/prose.rb"]
+
+ s.bindir = "bin"
+ s.default_executable = "melon"
+ s.executables = "melon"
+
+ s.add_dependency "prose", ">= 0.2"
+ s.add_dependency "json", ">= 0.2"
+ s.add_dependency "rack", ">= 0.9"
+end
@@ -0,0 +1,64 @@
+# Ruby
+require 'rack'
+require 'date'
+require 'digest'
+require 'json'
+
+require 'document'
+require 'router'
+
+# Load modules
+Dir.chdir('modules') do
+ puts '* Opening modules/'
+ require 'base/model'
+ require 'base/controller'
+ Dir.new('.').entries.each do |f|
+ unless File.directory?( f )
+ puts '* Found ' + f
+ require f
+ end
+ end
+end
+
+module Melon
+ class Server
+ def initialize
+ puts "*"
+ puts "* Initializing Melon..."
+ puts "* Ruby " + RUBY_VERSION
+
+ raise "Melon needs ruby 1.9.1 or higher!" if RUBY_VERSION < '1.9.1'
+ end
+
+ # Called on each request
+ def call env
+ Router.new( env ).go.finish
+ end
+ end
+
+end
+
+class Object
+ # Syntactic sugar for const_get()
+ def self.[]( const )
+ self.const_get( const )
+ end
+
+ # For modules
+ def []( const )
+ self.const_get( const )
+ end
+
+ def null
+ nil.to_json
+ end
+end
+
+class String
+ alias each each_line
+end
+
+class Array
+ def second; self[1] end
+ def third; self[2] end
+end
@@ -0,0 +1,9 @@
+require 'melon'
+
+# Rack config
+use Rack::Static, :urls => ['/css', '/js', '/images', '/html'], :root => 'public'
+use Rack::ShowExceptions
+use Rack::Session::Cookie
+
+# Run application
+run Melon::Server.new
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>currentDocument</key>
+ <string>Sites/melon/public/css/style.css</string>
+ <key>documents</key>
+ <array>
+ <dict>
+ <key>expanded</key>
+ <true/>
+ <key>name</key>
+ <string>melon</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
+ <key>sourceDirectory</key>
+ <string></string>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../../melon.ru</string>
+ <key>lastUsed</key>
+ <date>2009-04-10T05:07:29Z</date>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../../router.rb</string>
+ <key>lastUsed</key>
+ <date>2009-04-10T05:07:01Z</date>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../../server.rb</string>
+ <key>lastUsed</key>
+ <date>2009-04-10T05:07:02Z</date>
+ </dict>
+ <dict>
+ <key>filename</key>
+ <string>../../melon.rb</string>
+ <key>lastUsed</key>
+ <date>2009-04-10T05:07:07Z</date>
+ </dict>
+ </array>
+ <key>fileHierarchyDrawerWidth</key>
+ <integer>200</integer>
+ <key>metaData</key>
+ <dict>
+ <key>Sites/melon/modules/comments.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>0</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/modules/error.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>0</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/modules/session.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>0</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/public/css/style.css</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>18</integer>
+ <key>line</key>
+ <integer>18</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/public/html/articles/test.html</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>7</integer>
+ <key>line</key>
+ <integer>1</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/public/html/articles/test2.html</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>10</integer>
+ <key>line</key>
+ <integer>1</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/public/html/melon.html</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>2</integer>
+ <key>line</key>
+ <integer>16</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/public/js/jquery.js</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>40</integer>
+ <key>line</key>
+ <integer>3600</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>Sites/melon/public/js/melon.js</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>4</integer>
+ <key>line</key>
+ <integer>29</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>melon.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>3</integer>
+ <key>line</key>
+ <integer>19</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>melon.ru</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>5</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ <key>router.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>4</integer>
+ <key>line</key>
+ <integer>1</integer>
+ </dict>
+ <key>columnSelection</key>
+ <false/>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ <key>selectFrom</key>
+ <dict>
+ <key>column</key>
+ <integer>2</integer>
+ <key>line</key>
+ <integer>1</integer>
+ </dict>
+ <key>selectTo</key>
+ <dict>
+ <key>column</key>
+ <integer>7</integer>
+ <key>line</key>
+ <integer>1</integer>
+ </dict>
+ </dict>
+ <key>server.rb</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>0</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>openDocuments</key>
+ <array>
+ <string>melon.rb</string>
+ <string>server.rb</string>
+ <string>router.rb</string>
+ <string>Sites/melon/public/html/melon.html</string>
+ <string>Sites/melon/public/html/articles/test.html</string>
+ <string>Sites/melon/public/html/articles/test2.html</string>
+ <string>melon.ru</string>
+ <string>Sites/melon/modules/comments.rb</string>
+ <string>Sites/melon/public/js/jquery.js</string>
+ <string>Sites/melon/public/js/melon.js</string>
+ <string>Sites/melon/public/css/style.css</string>
+ <string>Sites/melon/modules/session.rb</string>
+ <string>Sites/melon/modules/error.rb</string>
+ </array>
+ <key>showFileHierarchyDrawer</key>
+ <true/>
+ <key>windowFrame</key>
+ <string>{{484, 25}, {765, 753}}</string>
+</dict>
+</plist>
Oops, something went wrong.

0 comments on commit 32e2274

Please sign in to comment.