Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

533 changes: 533 additions & 0 deletions .idea/topnews.iml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@ source 'https://rubygems.org'

ruby File.read('.ruby-version').chomp

gem 'byebug', platforms: [:mri, :mingw, :x64_mingw], group: [:development, :test]
gem 'capybara', group: [:development, :test]
gem 'byebug', platforms: %i[mri mingw x64_mingw], group: %i[development test]
gem 'capybara', group: %i[development test]
gem 'coffee-rails'
gem 'devise'
gem 'factory_bot_rails'
gem 'httparty'
gem 'jbuilder'
gem 'listen', group: :development
gem 'pg'
gem 'pry-rails'
gem 'puma'
gem 'rails', '~> 7.0.8'
gem 'redis'
gem 'rspec-rails'
gem 'rubocop', group: 'development', require: false
gem 'sass-rails'
gem 'selenium-webdriver', group: [:development, :test]
gem 'selenium-webdriver', group: %i[development test]
gem 'sidekiq'
gem 'sidekiq-cron', '~> 1.2'
gem 'sidekiq-scheduler'
gem 'sinatra', require: nil
gem 'spring', group: :development
gem 'turbolinks'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem 'uglifier'
gem 'web-console', group: :development
87 changes: 80 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.8)
bindex (0.8.1)
builder (3.3.0)
byebug (11.1.3)
Expand All @@ -91,7 +93,9 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
csv (3.3.0)
date (3.3.4)
devise (4.9.4)
bcrypt (~> 3.0)
Expand All @@ -101,24 +105,35 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.5.1)
erubi (1.13.0)
et-orbi (1.2.11)
tzinfo
execjs (2.9.1)
factory_bot (6.4.2)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
ffi (1.17.0)
ffi (1.17.0-arm64-darwin)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
jbuilder (2.12.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
logger (1.6.1)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -131,8 +146,11 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
net-imap (0.4.14)
date
net-protocol
Expand All @@ -143,10 +161,13 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pg (1.5.7)
pry (0.14.2)
coderay (~> 1.1)
Expand All @@ -156,8 +177,12 @@ GEM
public_suffix (6.0.1)
puma (6.4.2)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.1)
rack (2.2.9)
rack-protection (3.2.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.4)
Expand Down Expand Up @@ -188,10 +213,15 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
connection_pool
regexp_parser (2.9.2)
responders (3.1.1)
actionpack (>= 5.2)
Expand All @@ -215,7 +245,23 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rufus-scheduler (3.9.2)
fugit (~> 1.1, >= 1.11.1)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
Expand All @@ -232,6 +278,25 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sidekiq (7.3.2)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sidekiq-cron (1.12.0)
fugit (~> 1.8)
globalid (>= 1.0.1)
sidekiq (>= 6)
sidekiq-scheduler (5.0.6)
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
tilt (>= 1.4.0, < 3)
sinatra (3.2.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.2.0)
tilt (~> 2.0)
spring (4.2.1)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
Expand All @@ -251,6 +316,7 @@ GEM
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.6.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
Expand All @@ -267,23 +333,30 @@ GEM
zeitwerk (2.6.17)

PLATFORMS
ruby
arm64-darwin-24

DEPENDENCIES
byebug
capybara
coffee-rails
devise
factory_bot_rails
httparty
jbuilder
listen
pg
pry-rails
puma
rails (~> 7.0.8)
redis
rspec-rails
rubocop
sass-rails
selenium-webdriver
sidekiq
sidekiq-cron (~> 1.2)
sidekiq-scheduler
sinatra
spring
turbolinks
tzinfo-data
Expand All @@ -294,4 +367,4 @@ RUBY VERSION
ruby 3.2.3p157

BUNDLED WITH
2.3.22
2.4.19
6 changes: 6 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
//= require rails-ujs
//= require turbolinks
//= require_tree .
// app/assets/javascripts/application.js

//= require rails-ujs
//= require turbolinks
//= require_tree .
//= require stories
45 changes: 45 additions & 0 deletions app/assets/javascripts/stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
document.addEventListener('DOMContentLoaded', () => {
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');

document.querySelectorAll('.star').forEach(starElement => {
starElement.addEventListener('click', async (event) => {
const storyId = starElement.getAttribute('data-id');
const isStarred = starElement.classList.contains('starred');
const response = await fetch(`/stories/${storyId}/${isStarred ? 'unstar' : 'star'}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': csrfToken
}
});

if (response.ok) {
const json = await response.json();
if (json.success) {
starElement.classList.toggle('starred');
const isStarred = starElement.classList.contains('starred');
starElement.textContent = isStarred ? '★' : '☆';
updateStarredBy(starElement, json.starred_by);
window.location.reload();
} else {
console.error(json.message || 'Failed to star/unstar the story');
}
} else {
console.error('Failed to star/unstar the story');
}
});
});

function updateStarredBy(starElement, starredBy) {
const storyNode = starElement.closest('li');
const starredByElement = storyNode.querySelector('.starred-by');
if (starredByElement) {
if (starredBy.length > 0) {
starredByElement.textContent = `Starred by: ${starredBy.join(', ')}`;
} else {
starredByElement.textContent = 'Starred by: No one yet';
}
}
}

});
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

def after_sign_in_path_for(resource)
user_root_path
end
end
Loading