mongowiki 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +103 -0
  4. data/README.md +39 -0
  5. data/Rakefile +21 -0
  6. data/lib/assets/javascripts/application.js +6 -0
  7. data/lib/assets/javascripts/jquery.autoSearch.js +83 -0
  8. data/lib/assets/javascripts/jquery.preventTab.js +13 -0
  9. data/lib/assets/stylesheets/application.css +71 -0
  10. data/lib/assets/stylesheets/articles.css +53 -0
  11. data/lib/assets/stylesheets/buttons.css +127 -0
  12. data/lib/assets/stylesheets/coderay.css +133 -0
  13. data/lib/assets/stylesheets/error.css +17 -0
  14. data/lib/assets/stylesheets/forms.css +66 -0
  15. data/lib/assets/stylesheets/reset.css +48 -0
  16. data/lib/assets/stylesheets/search.css +77 -0
  17. data/lib/mongowiki.rb +47 -0
  18. data/lib/mongowiki/app.rb +61 -0
  19. data/lib/mongowiki/articles.rb +67 -0
  20. data/lib/mongowiki/helpers.rb +2 -0
  21. data/lib/mongowiki/helpers/markdown_helper.rb +18 -0
  22. data/lib/mongowiki/helpers/message_helper.rb +28 -0
  23. data/lib/mongowiki/models/article.rb +15 -0
  24. data/lib/mongowiki/search.rb +30 -0
  25. data/lib/mongowiki/version.rb +3 -0
  26. data/lib/views/404.erb +6 -0
  27. data/lib/views/article/edit.erb +2 -0
  28. data/lib/views/article/form.erb +23 -0
  29. data/lib/views/article/list.erb +8 -0
  30. data/lib/views/article/new.erb +2 -0
  31. data/lib/views/article/show.erb +12 -0
  32. data/lib/views/error.erb +16 -0
  33. data/lib/views/layout.erb +36 -0
  34. data/lib/views/search/articles.erb +7 -0
  35. data/lib/views/search/articles.rabl +8 -0
  36. data/mongowiki.gemspec +49 -0
  37. data/test/test_helper.rb +7 -0
  38. data/test/unit/application_test.rb +22 -0
  39. metadata +408 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ .sass-cache
3
+ .yardoc
4
+ config.ru
5
+ pkg
6
+ doc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongowiki (0.1.1)
5
+ activesupport (~> 3.2.0)
6
+ bson_ext (~> 1.5)
7
+ coderay (~> 1.0.6)
8
+ mongoid (~> 2.4)
9
+ mongoid_search (~> 0.2.7)
10
+ rabl (~> 0.6.10)
11
+ rack (~> 1.4.1)
12
+ rack-cache (~> 1.1.0)
13
+ rack-contrib (~> 1.1.0)
14
+ redcarpet (~> 2.1.0)
15
+ sass (~> 3.1.17)
16
+ sinatra (~> 1.3.2)
17
+ sinatra-contrib (~> 1.3.1)
18
+ sprockets (~> 2.1.2)
19
+ sprockets-helpers (~> 0.3.0)
20
+ yajl-ruby (~> 1.1.0)
21
+
22
+ GEM
23
+ remote: http://rubygems.org/
24
+ specs:
25
+ activemodel (3.2.3)
26
+ activesupport (= 3.2.3)
27
+ builder (~> 3.0.0)
28
+ activesupport (3.2.3)
29
+ i18n (~> 0.6)
30
+ 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)
35
+ builder (3.0.0)
36
+ coderay (1.0.6)
37
+ eventmachine (0.12.10)
38
+ fast-stemmer (1.0.1)
39
+ hike (1.2.1)
40
+ i18n (0.6.0)
41
+ kgio (2.7.4)
42
+ minitest (2.8.1)
43
+ mongo (1.6.2)
44
+ bson (~> 1.6.2)
45
+ mongoid (2.4.9)
46
+ activemodel (~> 3.1)
47
+ mongo (~> 1.3)
48
+ tzinfo (~> 0.3.22)
49
+ mongoid_search (0.2.7)
50
+ bson_ext (>= 1.2)
51
+ fast-stemmer (~> 1.0.0)
52
+ mongoid (>= 2.0.0)
53
+ multi_json (1.3.4)
54
+ rabl (0.6.10)
55
+ activesupport (>= 2.3.14)
56
+ multi_json (~> 1.0)
57
+ rack (1.4.1)
58
+ rack-cache (1.1)
59
+ rack (>= 0.4)
60
+ rack-contrib (1.1.0)
61
+ rack (>= 0.9.1)
62
+ rack-protection (1.2.0)
63
+ rack
64
+ rack-test (0.6.1)
65
+ rack (>= 1.0)
66
+ raindrops (0.8.0)
67
+ redcarpet (2.1.1)
68
+ sass (3.1.17)
69
+ sinatra (1.3.2)
70
+ rack (~> 1.3, >= 1.3.6)
71
+ rack-protection (~> 1.2)
72
+ tilt (~> 1.3, >= 1.3.3)
73
+ sinatra-contrib (1.3.1)
74
+ backports (>= 2.0)
75
+ eventmachine
76
+ rack-protection
77
+ rack-test
78
+ sinatra (~> 1.3.0)
79
+ tilt (~> 1.3)
80
+ sprockets (2.1.3)
81
+ hike (~> 1.2)
82
+ rack (~> 1.0)
83
+ tilt (~> 1.1, != 1.3.0)
84
+ sprockets-helpers (0.3.0)
85
+ sprockets (~> 2.0)
86
+ tilt (1.3.3)
87
+ tzinfo (0.3.33)
88
+ unicorn (4.2.1)
89
+ kgio (~> 2.6)
90
+ rack
91
+ raindrops (~> 0.7)
92
+ yajl-ruby (1.1.0)
93
+ yard (0.7.5)
94
+
95
+ PLATFORMS
96
+ ruby
97
+
98
+ DEPENDENCIES
99
+ minitest (~> 2.8.1)
100
+ mongowiki!
101
+ rack-test (~> 0.6.1)
102
+ unicorn
103
+ yard (~> 0.7.3)
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ mongowiki
2
+ =========
3
+
4
+ mongowiki is an sinatra-based rack-application which saves all data to an mongodb
5
+
6
+ Installation
7
+ ------------
8
+
9
+ $ gem install mongowiki
10
+
11
+ create a *config.ru* file somewhere on your filesystem, which is in my case */var/apps/mongowiki*
12
+
13
+ ENV['MONGO_URL'] = "mongodb://SERVER:27017/database"
14
+
15
+ require 'mongowiki'
16
+ 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
+
23
+ You can set all this variables in your **config.ru**
24
+
25
+ **MONGO_URL**
26
+ URI to the MongoDB instance. For example: mongodb://username:passwort@server:27017/database
27
+
28
+ Contribution
29
+ ------------
30
+
31
+ ### Patches & Pull Requests
32
+
33
+ You want to add a feature or you want to patch mongowiki?
34
+
35
+ 1. Fork the project.
36
+ 2. Make your feature addition or bug fix.
37
+ 3. Add tests for it. This is important so I don't break it in a future version unintentionally.
38
+ 4. Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
39
+ 5. Send me a pull request. Bonus points for topic branches.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "yard"
4
+
5
+ desc "generate documentation"
6
+ YARD::Rake::YardocTask.new do |t|
7
+ t.files << 'lib/**/*.rb'
8
+ end
9
+
10
+ namespace :test do
11
+ Rake::TestTask.new(:unit) do |task|
12
+ task.libs << "test"
13
+ task.test_files = FileList["test/unit/**/*_test.rb"]
14
+ end
15
+ end
16
+
17
+ task :test do
18
+ Rake::Task["test:unit"].invoke
19
+ end
20
+
21
+ task :default => [:test, :build, :yard]
@@ -0,0 +1,6 @@
1
+ //= require_tree .
2
+ //= require_self
3
+
4
+ $(function() {
5
+ $('#search input').autoSearch("/search.json", { minLength: 3 });
6
+ });
@@ -0,0 +1,83 @@
1
+ (function($){
2
+ $.fn.autoSearch = function(url, options) {
3
+
4
+ var input = $(this);
5
+ var requestRunning = false;
6
+ var request;
7
+
8
+ var defaults = {
9
+ minLength: 1,
10
+ queryParam: 'query',
11
+ noResultsClass: 'no-results',
12
+ resultListClass: 'result-list',
13
+ resultItemClass: 'result-item',
14
+ itemTitleClass: 'item-title',
15
+ itemExcerptClass: 'item-content'
16
+ };
17
+
18
+ var opts = $.extend(defaults, options);
19
+
20
+ $(input).keyup(function(event) {
21
+ event.preventDefault();
22
+ var query = $(input).val();
23
+
24
+ if(requestRunning) {
25
+ request.abort();
26
+ }
27
+
28
+ var resultList = $('.' + opts.resultListClass);
29
+ if(resultList.length <= 0) {
30
+ resultList = document.createElement('ul');
31
+ $(resultList).attr('class', opts.resultListClass);
32
+ $(resultList).appendTo(input.parent());
33
+ $(resultList).bind('mouseleave', function() {
34
+ $(resultList).hide();
35
+ });
36
+ }
37
+ $(resultList).hide();
38
+
39
+ if(query.length >= opts.minLength) {
40
+ $(resultList).empty();
41
+ runningRequest = true;
42
+ request = $.getJSON(url + '?' + opts.queryParam + '=' + query, function(data){
43
+ var articles = data.articles
44
+ if( articles.length > 0 ) {
45
+
46
+ if(input.hasClass(opts.noResultsClass)) {
47
+ $(input).removeClass(opts.noResultsClass);
48
+ }
49
+
50
+ $.each(articles, function(i, item) {
51
+
52
+ var listItem = document.createElement("li");
53
+ $(listItem).attr('class', opts.resultItemClass);
54
+
55
+ var link = document.createElement("a");
56
+ $(link).attr('class', opts.itemTitleClass);
57
+ $(link).attr('href', item.url);
58
+ $(link).appendTo(listItem);
59
+
60
+ var title = document.createElement("h2");
61
+ $(title).text(item.title);
62
+ $(title).appendTo(link);
63
+
64
+ var content = document.createElement("div");
65
+ $(content).attr('class', opts.itemExcerptClass);
66
+ $(content).text(item.excerpt);
67
+ $(content).appendTo(listItem);
68
+
69
+ $(listItem).appendTo(resultList);
70
+
71
+ });
72
+ $(resultList).show();
73
+ runningRequest = false;
74
+ } else {
75
+ $(resultList).hide();
76
+ $(input).addClass(opts.noResultsClass);
77
+ runningRequest = false;
78
+ }
79
+ });
80
+ }
81
+ });
82
+ };
83
+ })(jQuery);
@@ -0,0 +1,13 @@
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);
@@ -0,0 +1,71 @@
1
+ //= require reset
2
+ //= require_tree .
3
+ //= require_self
4
+
5
+ body {
6
+ color: #000;
7
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
8
+ background-color: #DDD;
9
+ }
10
+
11
+ h1, h2, h3, h4, h5, h6 {
12
+ font-weight: bold;
13
+ }
14
+
15
+ strong,b {
16
+ font-weight: bolder;
17
+ }
18
+
19
+ #wrapper {
20
+ width: 960px;
21
+ margin: 0 auto;
22
+ padding: 0 12px;
23
+ }
24
+
25
+ #wrapper #main-bar {
26
+ margin: 20px 0;
27
+ }
28
+
29
+ #navigation .list li {
30
+ display: inline-block;
31
+ margin: 0 5px 0 0;
32
+ }
33
+
34
+ #wrapper .title {
35
+ font-size: 20px;
36
+ font-weight: bold;
37
+ margin: 15px 0;
38
+ }
39
+
40
+ /*** FLOAT ***/
41
+ .left {
42
+ float: left;
43
+ }
44
+
45
+ .right {
46
+ float: right;
47
+ text-align: left;
48
+ }
49
+
50
+ .clear {
51
+ clear: both;
52
+ display: block;
53
+ overflow: hidden;
54
+ visibility: hidden;
55
+ width: 0;
56
+ height: 0;
57
+ }
58
+
59
+ .clearfix:before,
60
+ .clearfix:after {
61
+ content: '.';
62
+ display: block;
63
+ overflow: hidden;
64
+ visibility: hidden;
65
+ font-size: 0;
66
+ line-height: 0;
67
+ width: 0;
68
+ height: 0;
69
+ }
70
+
71
+ .clearfix:after { clear: both; }
@@ -0,0 +1,53 @@
1
+ .article .title {
2
+ margin: 15px 0 5px 0;
3
+ }
4
+
5
+ .article .text,
6
+ ul.articles {
7
+ padding: 15px;
8
+ margin: 5px 0;
9
+ font-family: "Helvetica Neue", Helvetica, serif;
10
+ font-size: 16px;
11
+
12
+ border-radius: 5px;
13
+ -o-border-radius: 5px;
14
+ -moz-border-radius: 5px;
15
+ -webkit-border-radius: 5px;
16
+
17
+ background: rgb(240,240,240);
18
+ border: 1px solid #CCC;
19
+ }
20
+
21
+ .article .text p {
22
+ margin: 10px 0;
23
+ }
24
+
25
+ .article .text a {
26
+ color: #000
27
+ }
28
+
29
+ .article .text a:hover {
30
+ color: #666
31
+ }
32
+
33
+ .article .text ol {
34
+ list-style-type: square;
35
+ list-style-position: inside;
36
+ }
37
+
38
+ .article .text ol li {
39
+ margin-top: 5px;
40
+ }
41
+
42
+ .article .actions {
43
+ margin-top: 20px;
44
+ }
45
+
46
+ ul.articles li.article {
47
+ display: block;
48
+ padding: 5px 0;
49
+ }
50
+
51
+ ul.articles li.article a {
52
+ color: #000;
53
+ }
@@ -0,0 +1,127 @@
1
+ input[type='submit'].button {
2
+ outline: none;
3
+ }
4
+
5
+ .button {
6
+ display: inline-block;
7
+ margin: 0;
8
+
9
+ border-radius: 5px;
10
+ -o-border-radius: 5px;
11
+ -moz-border-radius: 5px;
12
+ -webkit-border-radius: 5px;
13
+
14
+ color: #FFF;
15
+ text-decoration: none;
16
+ text-shadow: #000 1px 1px 0.2em;
17
+
18
+ font-weight: bold;
19
+ font-size: 12px;
20
+ padding: 10px;
21
+ background-image: linear-gradient(bottom, rgb(187,177,177) 1%, rgb(217,212,212) 100%);
22
+ background-image: -o-linear-gradient(bottom, rgb(187,177,177) 1%, rgb(217,212,212) 100%);
23
+ background-image: -moz-linear-gradient(bottom, rgb(187,177,177) 1%, rgb(217,212,212) 100%);
24
+ background-image: -webkit-linear-gradient(bottom, rgb(187,177,177) 1%, rgb(217,212,212) 100%);
25
+ background-image: -ms-linear-gradient(bottom, rgb(187,177,177) 1%, rgb(217,212,212) 100%);
26
+ background-image: -webkit-gradient(
27
+ linear,
28
+ left bottom,
29
+ left top,
30
+ color-stop(0.01, rgb(187,177,177)),
31
+ color-stop(1, rgb(217,212,212))
32
+ );
33
+
34
+ border-top: none;
35
+ border-left: 1px solid rgb(187,177,177);
36
+ border-right: 1px solid rgb(187,177,177);
37
+ border-bottom: 1px solid rgb(187,177,177);
38
+
39
+ outline: none;
40
+ margin: 0;
41
+ }
42
+
43
+ .button:hover {
44
+ background-image: linear-gradient(bottom, rgb(187,177,177) 100%, rgb(217,212,212) 1%);
45
+ background-image: -o-linear-gradient(bottom, rgb(187,177,177) 100%, rgb(217,212,212) 1%);
46
+ background-image: -moz-linear-gradient(bottom, rgb(187,177,177) 100%, rgb(217,212,212) 1%);
47
+ background-image: -webkit-linear-gradient(bottom, rgb(187,177,177) 100%, rgb(217,212,212) 1%);
48
+ background-image: -ms-linear-gradient(bottom, rgb(187,177,177) 100%, rgb(217,212,212) 1%);
49
+ background-image: -webkit-gradient(
50
+ linear,
51
+ left bottom,
52
+ left top,
53
+ color-stop(1, rgb(187,177,177)),
54
+ color-stop(0.01, rgb(217,212,212))
55
+ );
56
+ }
57
+
58
+ .button.red {
59
+ background-image: linear-gradient(bottom, rgb(170,11,0) 1%, rgb(221,14,0) 100%);
60
+ background-image: -o-linear-gradient(bottom, rgb(170,11,0) 1%, rgb(221,14,0) 100%);
61
+ background-image: -moz-linear-gradient(bottom, rgb(170,11,0) 1%, rgb(221,14,0) 100%);
62
+ background-image: -webkit-linear-gradient(bottom, rgb(170,11,0) 1%, rgb(221,14,0) 100%);
63
+ background-image: -ms-linear-gradient(bottom, rgb(170,11,0) 1%, rgb(221,14,0) 100%);
64
+ background-image: -webkit-gradient(
65
+ linear,
66
+ left bottom,
67
+ left top,
68
+ color-stop(0.01, rgb(170,11,0)),
69
+ color-stop(1, rgb(221,14,0))
70
+ );
71
+
72
+ border-top: none;
73
+ border-left: 1px solid rgb(144,9,0);
74
+ border-right: 1px solid rgb(144,9,0);
75
+ border-bottom: 1px solid rgb(144,9,0);
76
+ }
77
+
78
+ .button.red:hover {
79
+ background-image: linear-gradient(bottom, rgb(170,11,0) 100%, rgb(221,14,0) 1%);
80
+ background-image: -o-linear-gradient(bottom, rgb(170,11,0) 100%, rgb(221,14,0) 1%);
81
+ background-image: -moz-linear-gradient(bottom, rgb(170,11,0) 100%, rgb(221,14,0) 1%);
82
+ background-image: -webkit-linear-gradient(bottom, rgb(170,11,0) 100%, rgb(221,14,0) 1%);
83
+ background-image: -ms-linear-gradient(bottom, rgb(170,11,0) 100%, rgb(221,14,0) 1%);
84
+ background-image: -webkit-gradient(
85
+ linear,
86
+ left bottom,
87
+ left top,
88
+ color-stop(1, rgb(170,11,0)),
89
+ color-stop(0.01, rgb(221,14,0))
90
+ );
91
+ }
92
+
93
+ .button.blue {
94
+ background-image: linear-gradient(bottom, rgb(33,150,204) 1%, rgb(103,200,235) 100%);
95
+ background-image: -o-linear-gradient(bottom, rgb(33,150,204) 1%, rgb(103,200,235) 100%);
96
+ background-image: -moz-linear-gradient(bottom, rgb(33,150,204) 1%, rgb(103,200,235) 100%);
97
+ background-image: -webkit-linear-gradient(bottom, rgb(33,150,204) 1%, rgb(103,200,235) 100%);
98
+ background-image: -ms-linear-gradient(bottom, rgb(33,150,204) 1%, rgb(103,200,235) 100%);
99
+ background-image: -webkit-gradient(
100
+ linear,
101
+ left bottom,
102
+ left top,
103
+ color-stop(0.01, rgb(33,150,204)),
104
+ color-stop(1, rgb(103,200,235))
105
+ );
106
+
107
+ border-top: none;
108
+ border-left: 1px solid #0080FF;
109
+ border-right: 1px solid #0080FF;
110
+ border-bottom: 1px solid #579CDC;
111
+ }
112
+
113
+ .button.blue:hover {
114
+ background-image: linear-gradient(bottom, rgb(33,150,204) 100%, rgb(103,200,235) 1%);
115
+ background-image: -o-linear-gradient(bottom, rgb(33,150,204) 100%, rgb(103,200,235) 1%);
116
+ background-image: -moz-linear-gradient(bottom, rgb(33,150,204) 100%, rgb(103,200,235) 1%);
117
+ background-image: -webkit-linear-gradient(bottom, rgb(33,150,204) 100%, rgb(103,200,235) 1%);
118
+ background-image: -ms-linear-gradient(bottom, rgb(33,150,204) 100%, rgb(103,200,235) 1%);
119
+ background-image: -webkit-gradient(
120
+ linear,
121
+ left bottom,
122
+ left top,
123
+ color-stop(1, rgb(33,150,204)),
124
+ color-stop(0.01, rgb(103,200,235))
125
+ );
126
+
127
+ }