mongowiki 1.0.0.pre → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ruby-head
6
+ env: DB=mongodb MONGO_URL=mongodb://localhost/mongowiki_test
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongowiki (0.1.1)
4
+ mongowiki (1.0.0.pre)
5
5
  activesupport (~> 3.2.0)
6
6
  bson_ext (~> 1.5)
7
7
  coderay (~> 1.0.6)
8
+ diffy (~> 2.0.7)
8
9
  mongoid (~> 2.4)
9
10
  mongoid_search (~> 0.2.7)
10
11
  rabl (~> 0.6.10)
@@ -22,36 +23,41 @@ PATH
22
23
  GEM
23
24
  remote: http://rubygems.org/
24
25
  specs:
25
- activemodel (3.2.3)
26
- activesupport (= 3.2.3)
26
+ activemodel (3.2.6)
27
+ activesupport (= 3.2.6)
27
28
  builder (~> 3.0.0)
28
- activesupport (3.2.3)
29
+ activesupport (3.2.6)
29
30
  i18n (~> 0.6)
30
31
  multi_json (~> 1.0)
31
- backports (2.5.1)
32
- bson (1.6.2)
33
- bson_ext (1.6.2)
34
- bson (~> 1.6.2)
32
+ backports (2.6.1)
33
+ bson (1.6.4)
34
+ bson_ext (1.6.4)
35
+ bson (~> 1.6.4)
35
36
  builder (3.0.0)
36
- coderay (1.0.6)
37
+ coderay (1.0.7)
38
+ database_cleaner (0.6.7)
39
+ diffy (2.0.7)
37
40
  eventmachine (0.12.10)
38
41
  fast-stemmer (1.0.1)
39
42
  hike (1.2.1)
40
43
  i18n (0.6.0)
41
44
  kgio (2.7.4)
42
- minitest (2.8.1)
45
+ minitest (2.12.1)
43
46
  mongo (1.6.2)
44
47
  bson (~> 1.6.2)
45
- mongoid (2.4.9)
48
+ mongoid (2.4.11)
46
49
  activemodel (~> 3.1)
47
- mongo (~> 1.3)
50
+ mongo (<= 1.6.2)
48
51
  tzinfo (~> 0.3.22)
52
+ mongoid-minitest (0.0.3.1)
53
+ minitest (~> 2.12.0)
54
+ mongoid (~> 2.4.7)
49
55
  mongoid_search (0.2.7)
50
56
  bson_ext (>= 1.2)
51
57
  fast-stemmer (~> 1.0.0)
52
58
  mongoid (>= 2.0.0)
53
- multi_json (1.3.4)
54
- rabl (0.6.10)
59
+ multi_json (1.3.6)
60
+ rabl (0.6.14)
55
61
  activesupport (>= 2.3.14)
56
62
  multi_json (~> 1.0)
57
63
  rack (1.4.1)
@@ -63,9 +69,10 @@ GEM
63
69
  rack
64
70
  rack-test (0.6.1)
65
71
  rack (>= 1.0)
66
- raindrops (0.8.0)
72
+ raindrops (0.10.0)
73
+ rake (0.9.2.2)
67
74
  redcarpet (2.1.1)
68
- sass (3.1.17)
75
+ sass (3.1.20)
69
76
  sinatra (1.3.2)
70
77
  rack (~> 1.3, >= 1.3.6)
71
78
  rack-protection (~> 1.2)
@@ -85,19 +92,22 @@ GEM
85
92
  sprockets (~> 2.0)
86
93
  tilt (1.3.3)
87
94
  tzinfo (0.3.33)
88
- unicorn (4.2.1)
95
+ unicorn (4.3.1)
89
96
  kgio (~> 2.6)
90
97
  rack
91
98
  raindrops (~> 0.7)
92
99
  yajl-ruby (1.1.0)
93
- yard (0.7.5)
100
+ yard (0.8.2.1)
94
101
 
95
102
  PLATFORMS
96
103
  ruby
97
104
 
98
105
  DEPENDENCIES
99
- minitest (~> 2.8.1)
106
+ database_cleaner
107
+ minitest
108
+ mongoid-minitest
100
109
  mongowiki!
101
- rack-test (~> 0.6.1)
110
+ rack-test
111
+ rake
102
112
  unicorn
103
- yard (~> 0.7.3)
113
+ yard
data/README.md CHANGED
@@ -1,12 +1,19 @@
1
- mongowiki
2
- =========
1
+ # mongowiki
3
2
 
4
- mongowiki is an sinatra-based rack-application which saves all data to an mongodb
3
+ mongowiki is an sinatra-based wiki application, which persists your articles into an mongodb
5
4
 
6
- Installation
7
- ------------
5
+ ## Travis CI
6
+
7
+ [![Build Status](https://secure.travis-ci.org/gr4y/mongowiki.png?branch=master)](http://travis-ci.org/gr4y/mongowiki)
8
+
9
+ ## Installation
10
+ ### stable release
8
11
 
9
12
  $ gem install mongowiki
13
+
14
+ ### prerelease
15
+
16
+ $ gem install mongowiki --pre
10
17
 
11
18
  create a *config.ru* file somewhere on your filesystem, which is in my case */var/apps/mongowiki*
12
19
 
@@ -14,20 +21,13 @@ create a *config.ru* file somewhere on your filesystem, which is in my case */va
14
21
 
15
22
  require 'mongowiki'
16
23
  run MongoWiki.run!
17
-
18
- depending on how your mongodb server is configured, you need to set the corresponding environment variables.
19
-
20
- Environment variables
21
- --------------------
22
24
 
23
- You can set all this variables in your **config.ru**
25
+ #### Environment variables
24
26
 
25
27
  **MONGO_URL**
26
28
  URI to the MongoDB instance. For example: mongodb://username:passwort@server:27017/database
27
29
 
28
- Contribution
29
- ------------
30
-
30
+ ## Contribution
31
31
  ### Patches & Pull Requests
32
32
 
33
33
  You want to add a feature or you want to patch mongowiki?
data/Rakefile CHANGED
@@ -8,13 +8,23 @@ YARD::Rake::YardocTask.new do |t|
8
8
  end
9
9
 
10
10
  namespace :test do
11
+
12
+ desc "specs"
13
+ Rake::TestTask.new(:spec) do |task|
14
+ task.libs << "test"
15
+ task.test_files = FileList["test/spec/**/*_spec.rb"]
16
+ end
17
+
18
+ desc "unit tests"
11
19
  Rake::TestTask.new(:unit) do |task|
12
20
  task.libs << "test"
13
21
  task.test_files = FileList["test/unit/**/*_test.rb"]
14
22
  end
23
+
15
24
  end
16
25
 
17
26
  task :test do
27
+ Rake::Task["test:spec"].invoke
18
28
  Rake::Task["test:unit"].invoke
19
29
  end
20
30
 
data/TODO.md ADDED
@@ -0,0 +1,16 @@
1
+ # TODOs
2
+
3
+ - Tests
4
+ - Refactoring
5
+
6
+ ## Features
7
+
8
+ - <s>article versioning</s> and locking
9
+ - implement an export and import mechanism for articles into markdown
10
+ - add an markdown editor, maybe [pagedown](http://pagedown.googlecode.com/)?
11
+
12
+ ## Enhancements
13
+
14
+ - replace sprockets cause it's just plain annoying to deal with!
15
+ - migrate from erb to an much more readable template engine. ([slim](http://slim-lang.com) looks very promising)
16
+ - migrate from sinatra.rb to [happy.rb](https://github.com/hmans/happy)
@@ -3,7 +3,9 @@
3
3
  }
4
4
 
5
5
  .article .text,
6
- ul.articles {
6
+ ul.articles,
7
+ ul.versions,
8
+ .diff {
7
9
  padding: 15px;
8
10
  margin: 5px 0;
9
11
  font-family: "Helvetica Neue", Helvetica, serif;
@@ -50,4 +52,26 @@ ul.articles li.article {
50
52
 
51
53
  ul.articles li.article a {
52
54
  color: #000;
53
- }
55
+ }
56
+
57
+ ul.versions li.version a {
58
+ text-decoration: none;
59
+ color: #000;
60
+ }
61
+
62
+ ul.versions li.version.current {
63
+ color: #0080FF;
64
+ }
65
+
66
+ .compare .current-link::before {
67
+ content: '<=';
68
+ color: #666;
69
+ }
70
+
71
+ .compare .current-link {
72
+ margin-top: 10px;
73
+ display: inline-block;
74
+ color: black;
75
+ text-decoration: none;
76
+ }
77
+
@@ -0,0 +1,67 @@
1
+ .diff {
2
+ overflow: auto;
3
+ }
4
+
5
+ .diff ul {
6
+ background: #fff;
7
+ overflow: auto;
8
+ font-size: 14px;
9
+ list-style: none;
10
+ display: table;
11
+ width: 100%;
12
+ }
13
+
14
+ .diff del, .diff ins {
15
+ display: block;
16
+ text-decoration: none;
17
+ }
18
+
19
+ .diff del .symbol, .diff ins .symbol {
20
+ color: #666;
21
+ display: inline-block;
22
+ margin-right: 10px;
23
+ }
24
+
25
+ .diff li {
26
+ position: relative;
27
+ padding: 5px;
28
+ display: table-row;
29
+ height: 1em;
30
+ }
31
+
32
+ .diff li.ins {
33
+ background: #dfd;
34
+ color: #080;
35
+ }
36
+
37
+ .diff li.del {
38
+ background: #fee;
39
+ color: #b00;
40
+ }
41
+
42
+ .diff li:hover {
43
+ background:#ffc
44
+ }
45
+
46
+ .diff del, .diff ins, .diff span {
47
+ white-space: pre-wrap;
48
+ font-family: monospace;
49
+ }
50
+
51
+ .diff del strong {
52
+ font-weight:normal;
53
+ background:#fcc;
54
+ }
55
+
56
+ .diff ins strong {
57
+ font-weight:normal;
58
+ background:#9f9;
59
+ }
60
+
61
+ .diff li.diff-comment {
62
+ display: none;
63
+ }
64
+
65
+ .diff li.diff-block-info {
66
+ background: none repeat scroll 0 0 gray;
67
+ }
data/lib/mongowiki.rb CHANGED
@@ -11,6 +11,7 @@ require 'sprockets'
11
11
  require 'sprockets-helpers'
12
12
  require 'redcarpet'
13
13
  require 'coderay'
14
+ require 'diffy'
14
15
 
15
16
  require 'mongowiki/models/article'
16
17
  require 'mongowiki/helpers'
@@ -18,17 +19,27 @@ require 'mongowiki/articles'
18
19
  require 'mongowiki/search'
19
20
  require 'mongowiki/app'
20
21
 
22
+ Mongoid.logger.level = 3
23
+
21
24
  module MongoWiki
22
-
23
- class << self
24
25
 
26
+ #
27
+ # the application
28
+ #
29
+ # usage:
30
+ #
31
+ # MongoWiki.run!
32
+ class << self
33
+
25
34
  attr_reader :mongo_uri
26
35
 
36
+ # set mongo_uri
27
37
  def mongo_uri=(uri)
28
38
  Mongoid::Config.from_hash("uri" => uri)
29
39
  @@mongo_uri = uri
30
40
  end
31
-
41
+
42
+ # init application
32
43
  def init!
33
44
  if mongo_uri = ENV['MONGO_URL']
34
45
  self.mongo_uri = mongo_uri
@@ -36,7 +47,8 @@ module MongoWiki
36
47
  raise "environment variable MONGO_URL is not set!"
37
48
  end
38
49
  end
39
-
50
+
51
+ # run application
40
52
  def run!
41
53
  init!
42
54
  MongoWiki::App.run!
data/lib/mongowiki/app.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  module MongoWiki
2
+
3
+ # :nodoc:
2
4
  class App < Sinatra::Base
3
5
 
4
6
  # set paths
@@ -8,8 +10,7 @@ module MongoWiki
8
10
 
9
11
  # sinatra
10
12
  set :show_exceptions, true
11
- set :logging, false
12
-
13
+
13
14
  # sprockets
14
15
  set :sprockets, Sprockets::Environment.new(root)
15
16
  set :assets_prefix, '/'
@@ -22,10 +23,6 @@ module MongoWiki
22
23
  sprockets.append_path File.join(assets_path, "stylesheets")
23
24
  sprockets.append_path File.join(assets_path, "javascripts")
24
25
  sprockets.append_path File.join(assets_path, "images")
25
- if logging
26
- sprockets.logger = Logger.new($stdout)
27
- Mongoid.logger = Logger.new($stdout)
28
- end
29
26
 
30
27
  # Configure Sprockets::Helpers (if necessary)
31
28
  Sprockets::Helpers.configure do |config|
@@ -37,21 +34,27 @@ module MongoWiki
37
34
  Rabl.register!
38
35
 
39
36
  end
40
-
37
+
41
38
  helpers do
42
39
  include Sprockets::Helpers
43
40
  include MongoWiki::Helpers::MessageHelper
44
41
  include MongoWiki::Helpers::MarkdownHelper
45
42
  end
46
-
43
+
47
44
  include Rack::Utils
48
45
  include MongoWiki::Articles
49
46
  include MongoWiki::Search
50
-
47
+
51
48
  not_found do
52
49
  erb :"404"
53
50
  end
54
51
 
52
+ #
53
+ # indexing keywords of Article
54
+ # and creating an Rack::Cascade with sprockets and all includes
55
+ #
56
+ # MongoWiki::App.run!
57
+ #
55
58
  def self.run!
56
59
  Article.index_keywords!
57
60
  Rack::Cascade.new([sprockets, self])
@@ -1,9 +1,12 @@
1
+ # :nodoc:
1
2
  module MongoWiki
3
+
4
+ # ActiveSupport::Concern which includes all the actions for articles
2
5
  module Articles
3
6
  extend ActiveSupport::Concern
4
-
7
+
5
8
  included do
6
-
9
+
7
10
  get '/' do
8
11
  redirect url("/list")
9
12
  end
@@ -17,7 +20,7 @@ module MongoWiki
17
20
  erb :error
18
21
  end
19
22
  end
20
-
23
+
21
24
  get '/show/:id' do
22
25
  begin
23
26
  @article = Article.find(params[:id])
@@ -27,12 +30,28 @@ module MongoWiki
27
30
  erb :error
28
31
  end
29
32
  end
30
-
33
+
34
+ get '/show/:id/diff/:aVersion' do
35
+ begin
36
+
37
+ aVersion = params[:aVersion].to_i
38
+ @article = Article.find(params[:id])
39
+
40
+ @title_diff = @article.diff(aVersion, :title)
41
+ @text_diff = @article.diff(aVersion, :text)
42
+ erb :'article/diff'
43
+
44
+ rescue Mongoid::Errors::DocumentNotFound => e
45
+ @error = e
46
+ erb :error
47
+ end
48
+ end
49
+
31
50
  get '/new' do
32
51
  @article = Article.new
33
52
  erb :'article/new'
34
53
  end
35
-
54
+
36
55
  post '/create' do
37
56
  article = params[:article]
38
57
  @article = Article.create(params[:article])
@@ -41,12 +60,12 @@ module MongoWiki
41
60
  end
42
61
  redirect url("/show/#{@article._id}")
43
62
  end
44
-
63
+
45
64
  get '/edit/:id' do
46
65
  @article = Article.find(params[:id])
47
66
  erb :'article/edit'
48
67
  end
49
-
68
+
50
69
  post '/update/:id' do
51
70
  @article = Article.find(params[:id])
52
71
  @article.update_attributes(params[:article])
@@ -54,7 +73,7 @@ module MongoWiki
54
73
  redirect url("/show/#{@article._id}")
55
74
  end
56
75
  end
57
-
76
+
58
77
  get '/destroy/:id' do
59
78
  @article = Article.find(params[:id])
60
79
  if @article.delete
@@ -1,18 +1,30 @@
1
-
1
+ # :nodoc:
2
2
  module MongoWiki
3
3
 
4
+ # custom redcarpet markdown renderer
4
5
  class MarkdownRenderer < Redcarpet::Render::HTML
6
+
7
+ # higlight the block of code
5
8
  def block_code(code, language)
6
9
  CodeRay.highlight(code, language)
7
10
  end
8
- end
9
11
 
12
+ end
13
+
14
+ # :nodoc:
10
15
  module Helpers
16
+
17
+ # markdown helper
11
18
  module MarkdownHelper
19
+
20
+ # render markdown
12
21
  def markdown(text)
13
22
  markdown = Redcarpet::Markdown.new(MongoWiki::MarkdownRenderer, :fenced_code_blocks => true)
14
23
  markdown.render(text)
15
24
  end
25
+
16
26
  end
27
+
17
28
  end
29
+
18
30
  end
@@ -1,16 +1,20 @@
1
1
  module MongoWiki
2
2
 
3
+ # :nodoc:
3
4
  module Helpers
4
5
 
6
+ # helper for messages, like flash in rails
5
7
  module MessageHelper
6
-
8
+
9
+ # add an message to the session
7
10
  def message(type, message)
8
11
  if session[:messages].nil?
9
12
  session[:messages] = []
10
13
  end
11
14
  session[:messages] << { :type => type, :text => message }
12
15
  end
13
-
16
+
17
+ # returns an array of all messages
14
18
  def messages
15
19
  if session[:messages].nil?
16
20
  session[:messages] = []
@@ -1,15 +1,43 @@
1
+ # mongoid document
1
2
  class Article
2
3
 
3
4
  include Mongoid::Document
4
- include Mongoid::Search
5
+ include Mongoid::Timestamps
6
+ include Mongoid::Versioning
7
+ include Mongoid::Search
5
8
 
9
+ # document
6
10
  field :title, :type => String
7
11
  field :text
8
-
12
+
13
+ # search
9
14
  search_in :title, :text
10
-
15
+
16
+ # validations
11
17
  validates_presence_of :title
12
18
  validates_uniqueness_of :title
13
19
  validates_presence_of :text
14
-
20
+
21
+ # returns an Diffy::Diff object of the given field
22
+ def diff(aVersion, field)
23
+ version = get_version(aVersion)
24
+ if !version.nil?
25
+ Diffy::Diff.new(version[field], self[field], :include_plus_and_minus_in_html => true)
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ private
32
+ def get_version(aVersion)
33
+ version = nil
34
+ versions.each do |v|
35
+ if v.version.eql?(aVersion)
36
+ version = v
37
+ break
38
+ end
39
+ end
40
+ version
41
+ end
42
+
15
43
  end
@@ -1,4 +1,6 @@
1
1
  module MongoWiki
2
+
3
+ # ActiveSupport::Concern which does all the search functionality
2
4
  module Search
3
5
  extend ActiveSupport::Concern
4
6
 
@@ -18,7 +20,8 @@ module MongoWiki
18
20
  render :rabl, :'search/articles', :format => params[:format]
19
21
  end
20
22
  end
21
-
23
+
24
+ # search article
22
25
  def search!
23
26
  query = params[:query]
24
27
  @articles = Article.search(query)
@@ -26,5 +29,7 @@ module MongoWiki
26
29
  end
27
30
 
28
31
  end
32
+
29
33
  end
34
+
30
35
  end
@@ -1,3 +1,5 @@
1
+ # :nodoc:
1
2
  module MongoWiki
2
- VERSION = "1.0.0.pre"
3
+ # version number
4
+ VERSION = "1.0.0.pre1"
3
5
  end
@@ -0,0 +1,13 @@
1
+ <h2 class="title">diff between latest version and version <%= params[:aVersion] %></h2>
2
+
3
+ <section class="compare">
4
+
5
+ <h4>article title</h4>
6
+ <%= @title_diff.to_s(:html) %>
7
+
8
+ <h4>article text</h4>
9
+ <%= @text_diff.to_s(:html) %>
10
+
11
+ <a href="/show/<%= @article._id %>" class="button red">back</a>
12
+
13
+ </section>
@@ -9,11 +9,6 @@
9
9
  <p>
10
10
  <label for="article[text]">Text: </label>
11
11
  <textarea name="article[text]"><%= @article.text %></textarea>
12
- <script type="text/javascript">
13
- $(function() {
14
- $("textarea").preventTab();
15
- });
16
- </script>
17
12
  </p>
18
13
  <p>
19
14
  <label for="save"></label>
@@ -5,6 +5,14 @@
5
5
  <div class="text">
6
6
  <%= markdown(@article.text) %>
7
7
  </div>
8
+
9
+ <h2>versions</h2>
10
+ <ul class="versions">
11
+ <% @article.versions.each do |version| %>
12
+ <%= erb :'article/version', :locals => { :version => version } %>
13
+ <% end %>
14
+ </ul>
15
+
8
16
  <div class="actions">
9
17
  <a href="<%= url("/edit/#{@article._id}") %>" class="button">edit article</a>
10
18
  <a href="<%= url("/destroy/#{@article._id}") %>" class="button red">destroy article</a>
@@ -0,0 +1,5 @@
1
+ <li class="version">
2
+ <a href="/show/<%= @article._id %>/diff/<%= version.version %>">
3
+ <%= version.version %> - <%= version.created_at.strftime("%d-%m-%Y %H:%M:%S") %>
4
+ </a>
5
+ </li>
data/mongowiki.gemspec CHANGED
@@ -7,31 +7,32 @@ Gem::Specification.new do |s|
7
7
  s.version = MongoWiki::VERSION
8
8
  s.authors = ["Sascha Wessel"]
9
9
  s.email = ["swessel@gr4yweb.de"]
10
- s.homepage = "http://www.gr4yweb.de/gems/mongowiki"
11
- s.summary = %q{mongowiki is an sinatra-based rack-application which saves all data to an mongodb}
12
- s.description = %q{mongowiki is based on sinatra rack app with sprockets (and sass), mongoid and erb}
13
-
14
- s.rubyforge_project = "mongowiki"
15
-
10
+ s.homepage = "http://github.com/gr4y/mongowiki"
11
+ s.summary = %q{mongowiki is an sinatra-based wiki application, which persists your articles into an mongodb}
12
+ s.description = %q{mongowiki is an sinatra-based wiki application, which persists your articles into an mongodb}
13
+
16
14
  s.files = `git ls-files`.split("\n")
17
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
17
  s.require_paths = ["lib"]
20
18
 
21
19
  # development dependencies
22
- s.add_development_dependency "rack-test", "~> 0.6.1"
23
- s.add_development_dependency "minitest", "~> 2.8.1"
24
- s.add_development_dependency "yard", "~> 0.7.3"
20
+ s.add_development_dependency "rake"
21
+ s.add_development_dependency "rack-test"
22
+ s.add_development_dependency "minitest"
23
+ s.add_development_dependency "mongoid-minitest"
24
+ s.add_development_dependency "yard"
25
25
  s.add_development_dependency "unicorn"
26
+ s.add_development_dependency "database_cleaner"
26
27
 
27
28
  # base dependencies
28
- s.add_runtime_dependency 'rack', '~> 1.4.1'
29
- s.add_runtime_dependency 'rack-contrib', '~> 1.1.0'
30
- s.add_runtime_dependency 'rack-cache', '~> 1.1.0'
31
- s.add_runtime_dependency 'sinatra', '~> 1.3.2'
32
- s.add_runtime_dependency 'sinatra-contrib', '~> 1.3.1'
33
- s.add_runtime_dependency 'activesupport', '~> 3.2.0'
34
- s.add_runtime_dependency 'yajl-ruby', '~> 1.1.0'
29
+ s.add_runtime_dependency "rack", "~> 1.4.1"
30
+ s.add_runtime_dependency "rack-contrib", "~> 1.1.0"
31
+ s.add_runtime_dependency "rack-cache", "~> 1.1.0"
32
+ s.add_runtime_dependency "sinatra", "~> 1.3.2"
33
+ s.add_runtime_dependency "sinatra-contrib", "~> 1.3.1"
34
+ s.add_runtime_dependency "activesupport", "~> 3.2.0"
35
+ s.add_runtime_dependency "yajl-ruby", "~> 1.1.0"
35
36
 
36
37
  # database
37
38
  s.add_runtime_dependency "mongoid", "~> 2.4"
@@ -45,5 +46,5 @@ Gem::Specification.new do |s|
45
46
  s.add_runtime_dependency "sprockets-helpers", "~> 0.3.0"
46
47
  s.add_runtime_dependency "sass", "~> 3.1.17"
47
48
  s.add_runtime_dependency "rabl", "~> 0.6.10"
48
-
49
+ s.add_runtime_dependency "diffy", "~> 2.0.7"
49
50
  end
data/test/mock/base.rb ADDED
@@ -0,0 +1,16 @@
1
+ class MockBase < Sinatra::Base
2
+
3
+ # has to be set, so the views could be loaded
4
+ set :root, File.expand_path('../../lib', File.dirname(__FILE__))
5
+
6
+ # make sinatra to call the error handler
7
+ set :raise_errors, Proc.new { true }
8
+
9
+ # disable exceptions
10
+ set :show_exceptions, false
11
+
12
+ error do
13
+ "error: #{request.env['sinatra.error'].to_s}"
14
+ end
15
+
16
+ end
@@ -0,0 +1,5 @@
1
+ require 'mock/base'
2
+
3
+ class MockSearch < MockBase
4
+ include MongoWiki::Search
5
+ end
data/test/mongodb.yml ADDED
@@ -0,0 +1,2 @@
1
+ # url: mongodb://ATLANTIS/mongowiki_test
2
+ url: mongodb://localhost/mongowiki_test
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe Article do
4
+ subject { Article }
5
+
6
+ # Mongoid::Matchers::Document
7
+ it { must be_document }
8
+ it { must be_timestamped }
9
+ it { must be_stored_in(:articles) }
10
+ it { must have_field(:title).of_type(String) }
11
+ it { must have_field(:text) }
12
+
13
+ # Mongoid::Matchers::Validations
14
+ it { must validate_presence_of(:title) }
15
+ it { must validate_uniqueness_of(:title) }
16
+ it { must validate_presence_of(:text) }
17
+
18
+ # check if there's a _keywords field, cause of Mongoid::Search
19
+ it { must have_field(:_keywords) }
20
+
21
+ # check if versions are embedded
22
+ it { must embed_many(:versions) }
23
+
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'mock/search'
3
+
4
+ def app
5
+ MockSearch
6
+ end
7
+
8
+ describe "MongoWiki::Search" do
9
+
10
+ before :each do
11
+ Mongoid::Factory.build(Article, { :title => 'Once upon time',
12
+ :text => [*('A'..'Z')].sample(100).join })
13
+ end
14
+
15
+ it 'should return a json string' do
16
+ get '/search.json', :query => 'time'
17
+ refute_nil last_response.body
18
+ refute_equal 'nil', last_response.body
19
+ end
20
+
21
+ end
@@ -0,0 +1,40 @@
1
+ require 'minitest/autorun'
2
+ require 'rack/test'
3
+ require 'database_cleaner'
4
+ require 'mongoid-minitest'
5
+ require 'mongowiki'
6
+ require 'yaml'
7
+
8
+ ENV['MONGO_URL']='mongodb://localhost/mongowiki_test'
9
+
10
+ def mongo_url
11
+ url = ENV['MONGO_URL']
12
+ if !url
13
+ if !::File.exists?('test/mongodb.yml')
14
+ raise 'MONGO_URL environment variable not set and test/mongodb.yml not found'
15
+ end
16
+ yaml = YAML::load_file('test/mongodb.yml')
17
+ url = yaml['url']
18
+ end
19
+ url
20
+ end
21
+
22
+ # set mongo_url
23
+ Mongoid::Config.from_hash("uri" => mongo_url)
24
+
25
+ # setup DatabaseCleaner
26
+ DatabaseCleaner.strategy = :truncation
27
+
28
+ class MiniTest::Spec
29
+ include Mongoid::Matchers
30
+ include Rack::Test::Methods
31
+
32
+ before :each do
33
+ DatabaseCleaner.start
34
+ end
35
+
36
+ after :each do
37
+ DatabaseCleaner.clean
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongowiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre
4
+ version: 1.0.0.pre1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,56 +9,88 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-17 00:00:00.000000000 Z
12
+ date: 2012-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rack-test
16
32
  requirement: !ruby/object:Gem::Requirement
17
33
  none: false
18
34
  requirements:
19
- - - ~>
35
+ - - ! '>='
20
36
  - !ruby/object:Gem::Version
21
- version: 0.6.1
37
+ version: '0'
22
38
  type: :development
23
39
  prerelease: false
24
40
  version_requirements: !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
- - - ~>
43
+ - - ! '>='
28
44
  - !ruby/object:Gem::Version
29
- version: 0.6.1
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: minitest
32
48
  requirement: !ruby/object:Gem::Requirement
33
49
  none: false
34
50
  requirements:
35
- - - ~>
51
+ - - ! '>='
36
52
  - !ruby/object:Gem::Version
37
- version: 2.8.1
53
+ version: '0'
38
54
  type: :development
39
55
  prerelease: false
40
56
  version_requirements: !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
- - - ~>
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: mongoid-minitest
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
44
76
  - !ruby/object:Gem::Version
45
- version: 2.8.1
77
+ version: '0'
46
78
  - !ruby/object:Gem::Dependency
47
79
  name: yard
48
80
  requirement: !ruby/object:Gem::Requirement
49
81
  none: false
50
82
  requirements:
51
- - - ~>
83
+ - - ! '>='
52
84
  - !ruby/object:Gem::Version
53
- version: 0.7.3
85
+ version: '0'
54
86
  type: :development
55
87
  prerelease: false
56
88
  version_requirements: !ruby/object:Gem::Requirement
57
89
  none: false
58
90
  requirements:
59
- - - ~>
91
+ - - ! '>='
60
92
  - !ruby/object:Gem::Version
61
- version: 0.7.3
93
+ version: '0'
62
94
  - !ruby/object:Gem::Dependency
63
95
  name: unicorn
64
96
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +107,22 @@ dependencies:
75
107
  - - ! '>='
76
108
  - !ruby/object:Gem::Version
77
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: database_cleaner
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
78
126
  - !ruby/object:Gem::Dependency
79
127
  name: rack
80
128
  requirement: !ruby/object:Gem::Requirement
@@ -331,8 +379,24 @@ dependencies:
331
379
  - - ~>
332
380
  - !ruby/object:Gem::Version
333
381
  version: 0.6.10
334
- description: mongowiki is based on sinatra rack app with sprockets (and sass), mongoid
335
- and erb
382
+ - !ruby/object:Gem::Dependency
383
+ name: diffy
384
+ requirement: !ruby/object:Gem::Requirement
385
+ none: false
386
+ requirements:
387
+ - - ~>
388
+ - !ruby/object:Gem::Version
389
+ version: 2.0.7
390
+ type: :runtime
391
+ prerelease: false
392
+ version_requirements: !ruby/object:Gem::Requirement
393
+ none: false
394
+ requirements:
395
+ - - ~>
396
+ - !ruby/object:Gem::Version
397
+ version: 2.0.7
398
+ description: mongowiki is an sinatra-based wiki application, which persists your articles
399
+ into an mongodb
336
400
  email:
337
401
  - swessel@gr4yweb.de
338
402
  executables: []
@@ -340,17 +404,19 @@ extensions: []
340
404
  extra_rdoc_files: []
341
405
  files:
342
406
  - .gitignore
407
+ - .travis.yml
343
408
  - Gemfile
344
409
  - Gemfile.lock
345
410
  - README.md
346
411
  - Rakefile
412
+ - TODO.md
347
413
  - lib/assets/javascripts/application.js
348
414
  - lib/assets/javascripts/jquery.autoSearch.js
349
- - lib/assets/javascripts/jquery.preventTab.js
350
415
  - lib/assets/stylesheets/application.css
351
416
  - lib/assets/stylesheets/articles.css
352
417
  - lib/assets/stylesheets/buttons.css
353
418
  - lib/assets/stylesheets/coderay.css
419
+ - lib/assets/stylesheets/diff.css
354
420
  - lib/assets/stylesheets/error.css
355
421
  - lib/assets/stylesheets/forms.css
356
422
  - lib/assets/stylesheets/reset.css
@@ -365,19 +431,25 @@ files:
365
431
  - lib/mongowiki/search.rb
366
432
  - lib/mongowiki/version.rb
367
433
  - lib/views/404.erb
434
+ - lib/views/article/diff.erb
368
435
  - lib/views/article/edit.erb
369
436
  - lib/views/article/form.erb
370
437
  - lib/views/article/list.erb
371
438
  - lib/views/article/new.erb
372
439
  - lib/views/article/show.erb
440
+ - lib/views/article/version.erb
373
441
  - lib/views/error.erb
374
442
  - lib/views/layout.erb
375
443
  - lib/views/search/articles.erb
376
444
  - lib/views/search/articles.rabl
377
445
  - mongowiki.gemspec
378
- - test/test_helper.rb
379
- - test/unit/application_test.rb
380
- homepage: http://www.gr4yweb.de/gems/mongowiki
446
+ - test/mock/base.rb
447
+ - test/mock/search.rb
448
+ - test/mongodb.yml
449
+ - test/spec/article_spec.rb
450
+ - test/spec/rack/search_spec.rb
451
+ - test/spec_helper.rb
452
+ homepage: http://github.com/gr4y/mongowiki
381
453
  licenses: []
382
454
  post_install_message:
383
455
  rdoc_options: []
@@ -396,13 +468,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
396
468
  - !ruby/object:Gem::Version
397
469
  version: 1.3.1
398
470
  requirements: []
399
- rubyforge_project: mongowiki
471
+ rubyforge_project:
400
472
  rubygems_version: 1.8.24
401
473
  signing_key:
402
474
  specification_version: 3
403
- summary: mongowiki is an sinatra-based rack-application which saves all data to an
404
- mongodb
475
+ summary: mongowiki is an sinatra-based wiki application, which persists your articles
476
+ into an mongodb
405
477
  test_files:
406
- - test/test_helper.rb
407
- - test/unit/application_test.rb
478
+ - test/mock/base.rb
479
+ - test/mock/search.rb
480
+ - test/mongodb.yml
481
+ - test/spec/article_spec.rb
482
+ - test/spec/rack/search_spec.rb
483
+ - test/spec_helper.rb
408
484
  has_rdoc:
@@ -1,13 +0,0 @@
1
- (function($){
2
- $.fn.preventTab = function() {
3
- $(this).keydown(function(e) {
4
- // when the user presses the tab key
5
- if(e.keyCode == 9) {
6
- // preventing default behaviour
7
- e.preventDefault();
8
- // append tab to field value
9
- this.value += '\t'
10
- }
11
- });
12
- }
13
- })(jQuery);
data/test/test_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'rack/test'
3
- require 'mongowiki'
4
-
5
- if !ENV['MONGO_URL']
6
- ENV['MONGO_URL']="mongodb://ATLANTIS/mongowiki_test"
7
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ApplicationTest < MiniTest::Unit::TestCase
4
- include Rack::Test::Methods
5
-
6
- def app
7
- MongoWiki::run!
8
- end
9
-
10
- def testStylesheet
11
- get '/application.css'
12
- assert last_response.ok?
13
- last_response.headers['Content-Type'].must_equal "text/css"
14
- end
15
-
16
- def testJavascript
17
- get '/application.js'
18
- assert last_response.ok?
19
- last_response.headers['Content-Type'].must_equal "application/javascript"
20
- end
21
-
22
- end