easycomments 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/_config.yml +7 -2
- data/dashboard.rb +2 -2
- data/easycomments.gemspec +2 -2
- data/ec.rb +1 -1
- data/lib/easycomments/ec_configuration.rb +7 -1
- data/lib/easycomments/ec_dashboard_model.rb +10 -7
- data/lib/easycomments/ec_model.rb +16 -4
- data/lib/easycomments/ec_pagination.rb +20 -0
- data/lib/easycomments.rb +3 -1
- data/public/elements/ec-dashboard/ec-dashboard.html +97 -10
- data/public/elements/ec-login/ec-login.html +78 -0
- data/public/polymer-loader.html +1 -0
- data/public/polymer-loader.vulcanized.html +1 -1
- data/spec/ec/ec_dashboard_spec.rb +22 -5
- data/spec/ec/ec_spec.rb +38 -3
- data/spec/spec_helper.rb +2 -2
- data/views/index.html +1 -79
- metadata +10 -8
@@ -9,6 +9,7 @@ Airborne.configure do |config|
|
|
9
9
|
original_verbosity = $VERBOSE
|
10
10
|
$VERBOSE = nil
|
11
11
|
DB = Sequel.sqlite
|
12
|
+
DB.extension(:pagination)
|
12
13
|
$VERBOSE = original_verbosity
|
13
14
|
db_setup
|
14
15
|
end
|
@@ -26,8 +27,16 @@ describe 'ec_dasboard' do
|
|
26
27
|
|
27
28
|
describe "GET /comments" do
|
28
29
|
it "returns the comments successfully" do
|
29
|
-
get "/comments
|
30
|
-
expect_json_types({:comments => :array_of_objects})
|
30
|
+
get URI.encode("/comments?post=#{example_post}&page=1")
|
31
|
+
expect_json_types({:comments => :array_of_objects, :page_count => :int})
|
32
|
+
end
|
33
|
+
it "uses page 1 by default" do
|
34
|
+
get URI.encode("/comments?post=#{example_post}")
|
35
|
+
expect_json_types({:comments => :array_of_objects, :page_count => :int})
|
36
|
+
end
|
37
|
+
it "fallbacks to page 1 with wrong page input" do
|
38
|
+
get URI.encode("/comments?post=#{example_post}&page=-3")
|
39
|
+
expect_json_types({:comments => :array_of_objects, :page_count => :int})
|
31
40
|
end
|
32
41
|
end
|
33
42
|
describe "GET /get_all_posts" do
|
@@ -49,9 +58,17 @@ describe 'ec_dasboard' do
|
|
49
58
|
end
|
50
59
|
end
|
51
60
|
describe "GET /get_pending_comments" do
|
52
|
-
it "returns the
|
53
|
-
get "/get_pending_comments
|
54
|
-
expect_json_types({:comments => :array_of_objects})
|
61
|
+
it "returns the comments successfully" do
|
62
|
+
get URI.encode("/get_pending_comments?post=#{example_post}&page=1")
|
63
|
+
expect_json_types({:comments => :array_of_objects, :page_count => :int})
|
64
|
+
end
|
65
|
+
it "uses page 1 by default" do
|
66
|
+
get URI.encode("/get_pending_comments?post=#{example_post}")
|
67
|
+
expect_json_types({:comments => :array_of_objects, :page_count => :int})
|
68
|
+
end
|
69
|
+
it "fallbacks to page 1 with wrong page input" do
|
70
|
+
get URI.encode("/get_pending_comments?post=#{example_post}&page=-3")
|
71
|
+
expect_json_types({:comments => :array_of_objects, :page_count => :int})
|
55
72
|
end
|
56
73
|
end
|
57
74
|
describe "POST /edit_comment" do
|
data/spec/ec/ec_spec.rb
CHANGED
@@ -9,6 +9,7 @@ Airborne.configure do |config|
|
|
9
9
|
original_verbosity = $VERBOSE
|
10
10
|
$VERBOSE = nil
|
11
11
|
DB = Sequel.sqlite
|
12
|
+
DB.extension(:pagination)
|
12
13
|
$VERBOSE = original_verbosity
|
13
14
|
db_setup
|
14
15
|
end
|
@@ -28,6 +29,18 @@ Airborne.configure do |config|
|
|
28
29
|
add_new_comment
|
29
30
|
config.rack_app = EC
|
30
31
|
end
|
32
|
+
config.before(:each, :paginate => false) do
|
33
|
+
original_verbosity = $VERBOSE
|
34
|
+
$VERBOSE = nil
|
35
|
+
PAGINATE = false
|
36
|
+
$VERBOSE = original_verbosity
|
37
|
+
end
|
38
|
+
config.before(:each, :paginate => true) do
|
39
|
+
original_verbosity = $VERBOSE
|
40
|
+
$VERBOSE = nil
|
41
|
+
PAGINATE = true
|
42
|
+
$VERBOSE = original_verbosity
|
43
|
+
end
|
31
44
|
end
|
32
45
|
|
33
46
|
describe 'ec' do
|
@@ -73,9 +86,31 @@ describe 'ec' do
|
|
73
86
|
end
|
74
87
|
end
|
75
88
|
describe "GET /comments" do
|
76
|
-
|
77
|
-
|
78
|
-
|
89
|
+
context "pagination is off" do
|
90
|
+
it "returns the comments successfully", :paginate => false do
|
91
|
+
get URI.encode("/comments?post=#{example_post}")
|
92
|
+
expect_json_types({:comments => :array_of_objects})
|
93
|
+
end
|
94
|
+
it "it ignores page parameter", :paginate => false do
|
95
|
+
get URI.encode("/comments?post=#{example_post}&page=1")
|
96
|
+
expect_json_types({:comments => :array_of_objects})
|
97
|
+
end
|
98
|
+
end
|
99
|
+
context "pagination is on" do
|
100
|
+
it "returns the comments successfully", :paginate => true do
|
101
|
+
get URI.encode("/comments?post=#{example_post}&page=1")
|
102
|
+
expect_json_types({:comments => :array_of_objects, :page => :int, :total_pages => :int})
|
103
|
+
end
|
104
|
+
it "uses page 1 by default", :paginate => true do
|
105
|
+
get URI.encode("/comments?post=#{example_post}")
|
106
|
+
expect_json_types({:comments => :array_of_objects, :page => :int, :total_pages => :int})
|
107
|
+
expect(json_body[:page]).to be == 1
|
108
|
+
end
|
109
|
+
it "fallbacks to page 1 with wrong page input", :paginate => true do
|
110
|
+
get URI.encode("/comments?post=#{example_post}&page=-3")
|
111
|
+
expect_json_types({:comments => :array_of_objects, :page => :int, :total_pages => :int})
|
112
|
+
expect(json_body[:page]).to be == 1
|
113
|
+
end
|
79
114
|
end
|
80
115
|
end
|
81
116
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,8 +11,8 @@ def db_setup
|
|
11
11
|
String :email
|
12
12
|
String :post
|
13
13
|
String :body
|
14
|
-
TrueClass :approved, :default=>
|
15
|
-
TrueClass :action_taken, :default=>false
|
14
|
+
TrueClass :approved, :default => true
|
15
|
+
TrueClass :action_taken, :default => false
|
16
16
|
DateTime :timestamp
|
17
17
|
end
|
18
18
|
|
data/views/index.html
CHANGED
@@ -7,82 +7,4 @@
|
|
7
7
|
<link rel="import" href="/polymer-loader.vulcanized.html">
|
8
8
|
</head>
|
9
9
|
|
10
|
-
<
|
11
|
-
<template>
|
12
|
-
<style>
|
13
|
-
#container {
|
14
|
-
background-color: #E5E5E5;
|
15
|
-
font-family: 'RobotoDraft', sans-serif;
|
16
|
-
width: 100%;
|
17
|
-
height: 100%;
|
18
|
-
}
|
19
|
-
#login_form {
|
20
|
-
width: 280px;
|
21
|
-
height: 260px;
|
22
|
-
margin-top: 10%;
|
23
|
-
}
|
24
|
-
a {
|
25
|
-
text-decoration: none !important;
|
26
|
-
color: #616161;
|
27
|
-
}
|
28
|
-
#title {
|
29
|
-
padding-left:50px;
|
30
|
-
}
|
31
|
-
#login_button::shadow #ripple {
|
32
|
-
color: #FFA726;
|
33
|
-
}
|
34
|
-
paper-input-decorator /deep/ .focused-underline {
|
35
|
-
/* line color when the input is focused */
|
36
|
-
background-color: #FFB74D;
|
37
|
-
}
|
38
|
-
paper-input-decorator /deep/ #floatedLabelText {
|
39
|
-
color: #616161;
|
40
|
-
}
|
41
|
-
</style>
|
42
|
-
<core-ajax
|
43
|
-
id="login"
|
44
|
-
url="/dashboard/login"
|
45
|
-
method="post"
|
46
|
-
params='{"username":"{{username}}", "password":"{{password}}"}'
|
47
|
-
handleAs="json"
|
48
|
-
on-core-response="{{postLogin}}">
|
49
|
-
</core-ajax>
|
50
|
-
<div horizontal center-justified layout id="container">
|
51
|
-
<paper-shadow id="login_form" vertical layout>
|
52
|
-
<paper-shadow><div id="title"><a href="/"><h2>EasyComments<h2></a></div></paper-shadow>
|
53
|
-
<paper-input-decorator label="Username" floatingLabel>
|
54
|
-
<input id="username" is="core-input" type="text" value="{{username}}"/>
|
55
|
-
</paper-input-decorator>
|
56
|
-
<paper-input-decorator label="Password" floatingLabel>
|
57
|
-
<input id="password" is="core-input" type="password" value="{{password}}"/>
|
58
|
-
</paper-input-decorator>
|
59
|
-
<paper-button id="login_button" on-click="{{login}}">Login</paper-button>
|
60
|
-
</paper-shadow>
|
61
|
-
</div>
|
62
|
-
<template if="{{has_access}}">
|
63
|
-
<ec-dashboard></ec-dashboard>
|
64
|
-
</template>
|
65
|
-
<paper-toast id="toast1" text="Wrong username or password."></paper-toast>
|
66
|
-
</template>
|
67
|
-
<script>
|
68
|
-
Polymer('ec-index', {
|
69
|
-
login: function() {
|
70
|
-
this.shadowRoot.querySelector("#login").go();
|
71
|
-
},
|
72
|
-
postLogin: function(event, response) {
|
73
|
-
this.has_access = response.response.has_access;
|
74
|
-
if(this.has_access === false){
|
75
|
-
this.shadowRoot.querySelector('#toast1').show();
|
76
|
-
}else{
|
77
|
-
//hide the form
|
78
|
-
this.shadowRoot.querySelector("#container").hidden = true;
|
79
|
-
}
|
80
|
-
},
|
81
|
-
ready: function(){
|
82
|
-
this.has_access = false;
|
83
|
-
},
|
84
|
-
});
|
85
|
-
</script>
|
86
|
-
</polymer-element>
|
87
|
-
|
88
|
-
<ec-index></ec-index>
|
10
|
+
<ec-login></ec-login>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easycomments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zisis Maras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
EasyComments(EC) is an easy to use comment system with a simple api
|
@@ -20,9 +20,9 @@ executables:
|
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
|
-
- .gitignore
|
24
|
-
- .rspec
|
25
|
-
- .travis.yml
|
23
|
+
- ".gitignore"
|
24
|
+
- ".rspec"
|
25
|
+
- ".travis.yml"
|
26
26
|
- Gemfile
|
27
27
|
- LICENSE
|
28
28
|
- README.md
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/easycomments/ec_configuration.rb
|
38
38
|
- lib/easycomments/ec_dashboard_model.rb
|
39
39
|
- lib/easycomments/ec_model.rb
|
40
|
+
- lib/easycomments/ec_pagination.rb
|
40
41
|
- public/bower.json
|
41
42
|
- public/bower_components/core-a11y-keys/.bower.json
|
42
43
|
- public/bower_components/core-a11y-keys/README.md
|
@@ -392,6 +393,7 @@ files:
|
|
392
393
|
- public/bower_components/webcomponentsjs/webcomponents.min.js
|
393
394
|
- public/css/main.css
|
394
395
|
- public/elements/ec-dashboard/ec-dashboard.html
|
396
|
+
- public/elements/ec-login/ec-login.html
|
395
397
|
- public/polymer-loader.html
|
396
398
|
- public/polymer-loader.vulcanized.html
|
397
399
|
- spec/ec/ec_dashboard_spec.rb
|
@@ -408,17 +410,17 @@ require_paths:
|
|
408
410
|
- lib
|
409
411
|
required_ruby_version: !ruby/object:Gem::Requirement
|
410
412
|
requirements:
|
411
|
-
- -
|
413
|
+
- - ">="
|
412
414
|
- !ruby/object:Gem::Version
|
413
415
|
version: '0'
|
414
416
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
415
417
|
requirements:
|
416
|
-
- -
|
418
|
+
- - ">="
|
417
419
|
- !ruby/object:Gem::Version
|
418
420
|
version: '0'
|
419
421
|
requirements: []
|
420
422
|
rubyforge_project:
|
421
|
-
rubygems_version: 2.4.
|
423
|
+
rubygems_version: 2.4.6
|
422
424
|
signing_key:
|
423
425
|
specification_version: 4
|
424
426
|
summary: Simple and easy to use comment system
|