Skip to content

Commit

Permalink
Merge branch 'master' into feature/add-tag-management
Browse files Browse the repository at this point in the history
  • Loading branch information
masongup committed Feb 1, 2018
2 parents f98b895 + 826c88f commit cbd484e
Show file tree
Hide file tree
Showing 50 changed files with 639 additions and 250 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ language: ruby
services:
- mysql
env:
- DATABASE_URL=mysql2://root:@localhost/lobsters_test
global:
- DATABASE_URL=mysql2://root:@localhost/lobsters_dev
- RAILS_ENV=test
before_script:
- ./bin/rails db:create
- ./bin/rails db:schema:load
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ gem "mysql2", ">= 0.3.14"
# uncomment to use PostgreSQL
# gem "pg"

gem 'scenic'
gem 'scenic-mysql'

gem "uglifier", ">= 1.3.0"
gem "jquery-rails", "~> 4.3"
gem "dynamic_form"
Expand Down
15 changes: 11 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
mini_portile2 (2.3.0)
minitest (5.10.2)
mysql2 (0.4.6)
nio4r (2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
oauth (0.5.3)
rack (2.0.3)
rack-test (0.6.3)
Expand Down Expand Up @@ -132,6 +132,11 @@ GEM
rspec-support (3.6.0)
ruby-enum (0.7.1)
i18n
scenic (1.4.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
scenic-mysql (0.1.0)
scenic (>= 1.3)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -175,9 +180,11 @@ DEPENDENCIES
rotp
rqrcode
rspec-rails (~> 3.6)
scenic
scenic-mysql
sqlite3
uglifier (>= 1.3.0)
unicorn

BUNDLED WITH
1.13.6
1.15.4
106 changes: 61 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,84 +22,100 @@ file.
* Install Ruby 2.3.

* Checkout the lobsters git tree from Github

$ git clone git://github.com/lobsters/lobsters.git
$ cd lobsters
lobsters$
```sh
$ git clone git://github.com/lobsters/lobsters.git
$ cd lobsters
lobsters$
```

* Install Nodejs, needed (or other execjs) for uglifier

Fedora: sudo yum install nodejs
Ubuntu: sudo apt-get install nodejs
OSX: brew install nodejs
```sh
Fedora: sudo yum install nodejs
Ubuntu: sudo apt-get install nodejs
OSX: brew install nodejs
```

* Run Bundler to install/bundle gems needed by the project:

lobsters$ bundle
```sh
lobsters$ bundle
```

* Create a MySQL (other DBs supported by ActiveRecord may work, only MySQL and
MariaDB have been tested) database, username, and password and put them in a
`config/database.yml` file. You will also want a separate database for
running tests:

development:
adapter: mysql2
encoding: utf8mb4
reconnect: false
database: lobsters_dev
socket: /tmp/mysql.sock
username: *dev_username*
password: *dev_password*
test:
adapter: mysql2
encoding: utf8mb4
reconnect: false
database: lobsters_test
socket: /tmp/mysql.sock
username: *test_username*
password: *test_password*
```yaml
development:
adapter: mysql2
encoding: utf8mb4
reconnect: false
database: lobsters_dev
socket: /tmp/mysql.sock
username: *dev_username*
password: *dev_password*
test:
adapter: mysql2
encoding: utf8mb4
reconnect: false
database: lobsters_test
socket: /tmp/mysql.sock
username: *test_username*
password: *test_password*
```

* Load the schema into the new database:

lobsters$ rake db:schema:load
```sh
lobsters$ rake db:schema:load
```

* Create a `config/initializers/secret_token.rb` file, using a randomly
generated key from the output of `rake secret`:

Lobsters::Application.config.secret_key_base = 'your random secret here'
```sh
Lobsters::Application.config.secret_key_base = 'your random secret here'
```

* Define your site's name and default domain, which are used in various places,
in a `config/initializers/production.rb` or similar file:
class << Rails.application
def domain
"example.com"
end
def name
"Example News"
end
end
Rails.application.routes.default_url_options[:host] = Rails.application.domain
```ruby
class << Rails.application
def domain
"example.com"
end
def name
"Example News"
end
end
Rails.application.routes.default_url_options[:host] = Rails.application.domain
```
* Put your site's custom CSS in `app/assets/stylesheets/local`.

* Seed the database to create an initial administrator user and at least one tag:
* Seed the database to create an initial administrator user, the `inactive-user`, and at least one tag:

lobsters$ rake db:seed
created user: test, password: test
created tag: test
```sh
lobsters$ rake db:seed
```

* Run the Rails server in development mode. You should be able to login to
`http://localhost:3000` with your new `test` user:

lobsters$ rails server
```sh
lobsters$ rails server
```

* In production, set up crontab or another scheduler to run regular jobs:

*/5 * * * * cd /path/to/lobsters && env RAILS_ENV=production sh -c 'bundle exec ruby script/mail_new_activity; bundle exec ruby script/post_to_twitter'
```
*/5 * * * * cd /path/to/lobsters && env RAILS_ENV=production sh -c 'bundle exec ruby script/mail_new_activity; bundle exec ruby script/post_to_twitter'
```

#### Administration

Expand Down
39 changes: 23 additions & 16 deletions app/assets/javascripts/application.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,25 @@ var _Lobsters = Class.extend({
d.append(a);
});

if (thingType == "story")
li.after(d);
else
if (thingType == "story") {
$(voterEl).after(d);

d.position({
my: "left top",
at: "left bottom",
offset: "-2 -2",
of: $(voterEl),
collision: "none",
});

/* XXX: why is this needed? */
if (thingType == "story")
d.position({
my: "left top",
at: "left bottom",
offset: "-2 -2",
of: $(voterEl),
collision: "none",
});
d.css("left", $(voterEl).position().left);
} else {
// place downvote menu outside of the comment to avoid inheriting opacity
var voterPos = $(voterEl).position();
d.appendTo($(voterEl).closest(".comments_subtree"));
d.css({
left: voterPos.left,
top: voterPos.top + $(voterEl).outerHeight()
});
}
},

vote: function(thingType, voterEl, point, reason) {
Expand Down Expand Up @@ -200,9 +203,13 @@ var _Lobsters = Class.extend({

postComment: function(form) {
$.post($(form).attr("action"), $(form).serializeArray(), function(data) {
if ($(form).find('#parent_comment_short_id').length) {
$(form).closest('.comment').replaceWith($.parseHTML(data));
if ($(form).find("#parent_comment_short_id").length) {
// reply to comment
$(form).closest(".comments_subtree")
.find(".comment_parent_tree_line:first").removeClass("no_children");
$(form).closest(".comment").replaceWith($.parseHTML(data));
} else {
// reply to story
$(form).parent(".comment").replaceWith($.parseHTML(data));
}
});
Expand Down
15 changes: 14 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ button:disabled {
color: gray;
}

input.deletion {
color: darkred;
border: 1px solid darkred;
}

.totp_code::-webkit-inner-spin-button,
.totp_code::-webkit-outer-spin-button {
-webkit-appearance: none;
Expand Down Expand Up @@ -606,6 +611,9 @@ li .comment_parent_tree_line.score_shown {
li .comment_parent_tree_line.can_downvote {
top: 56px;
}
li .comment_parent_tree_line.no_children {
border-left-color: transparent;
}
li .comment_siblings_tree_line {
position: absolute;
left: 28px;
Expand Down Expand Up @@ -822,7 +830,7 @@ a.pagelink.curpage {
width: 100px;
border: 1px solid #ccc;
border-bottom: 0;
z-index: 2;
z-index: 15;
}
#downvote_why a {
background-color: white;
Expand Down Expand Up @@ -914,6 +922,11 @@ div.comment_form_container textarea {
width: 100%;
}

span.comment_unread {
color: #ac130d;
font-weight: 600;
}

/* trees */

.tree,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
comment.comment = params[:comment].to_s
comment.user = @user

if params[:hat_id] && @user.hats.where(:id => params[:hat_id])
if params[:hat_id] && @user.wearable_hats.where(:id => params[:hat_id])
comment.hat_id = params[:hat_id]
end

Expand Down Expand Up @@ -135,7 +135,7 @@ def update

comment.comment = params[:comment]
comment.hat_id = nil
if params[:hat_id] && @user.hats.where(:id => params[:hat_id])
if params[:hat_id] && @user.wearable_hats.where(:id => params[:hat_id])
comment.hat_id = params[:hat_id]
end

Expand Down
Loading

0 comments on commit cbd484e

Please sign in to comment.