Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished #303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 5 additions & 22 deletions Gemfile.lock
Expand Up @@ -128,7 +128,6 @@ GEM
marcel (1.0.2)
matrix (0.4.2)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.21.2)
msgpack (1.7.2)
mutex_m (0.2.0)
Expand All @@ -142,16 +141,7 @@ GEM
net-smtp (0.4.0.1)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.0-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.0-x86_64-linux)
nokogiri (1.16.0-x64-mingw-ucrt)
racc (~> 1.4)
psych (5.1.2)
stringio
Expand Down Expand Up @@ -216,12 +206,7 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.7.1)
mini_portile2 (~> 2.8.0)
sqlite3 (1.7.1-aarch64-linux)
sqlite3 (1.7.1-arm64-darwin)
sqlite3 (1.7.1-x86_64-darwin)
sqlite3 (1.7.1-x86_64-linux)
sqlite3 (1.7.1-x64-mingw-ucrt)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
Expand All @@ -233,6 +218,8 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.4)
tzinfo (>= 1.0.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -252,11 +239,7 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
aarch64-linux
arm64-darwin
ruby
x86_64-darwin
x86_64-linux
x64-mingw-ucrt

DEPENDENCIES
bootsnap
Expand Down
26 changes: 26 additions & 0 deletions app/views/articles/edit.html.erb
@@ -0,0 +1,26 @@
<div class="articles">
<div class="containers">
<%= form_for(@article) do |f| %>
<div class="field">
<%= f.label :title %><br>
<%= f.text_area :title, placeholder: 'Enter title' %>
</div>
<div class="field">
<%= f.label :content %><br>
<%= f.text_area :content, placeholder: 'Enter content' %>
</div>
<div class="field">
<%= f.label :author %><br>
<%= f.text_area :author, placeholder: 'Enter author' %>
</div>
<div class="field">
<%= f.label :date %><br>
<%= f.date_field :date, value: @article.date || Date.today %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>

</div>
</div>
33 changes: 33 additions & 0 deletions app/views/articles/index.html.erb
@@ -0,0 +1,33 @@
<div class="articles">
<div class="container">

<!--Have post count as first thing on page-->
<p>Post count: <%= @article_count %></p>

<!--If there are any articles, show each of them (title & content) + edit option + delete option-->
<% if @articles.present? %>
<% @articles.each do |article| %>
<div class="article">
<p class="title"><%= article.title %></p>
<p class="content"><%= article.content %></p>
</div>
<%= link_to 'Edit Article', edit_article_path(article) %>
<%= link_to 'Delete Article', article_path(article) %>
<% end %>
<% else %>
<p>No matching articles found.</p>
<% end %>
<br>
<br>

<!--Create a new article!-->
<%= link_to 'New Article', "articles/new" %>

<!--Search for an article; get request + SQL search using search parameter (whatever the user enters)-->
<%= form_tag(articles_path, method: :get) do %>
<%= text_field_tag :search, params[:search], placeholder: 'Search articles...' %>
<%= submit_tag 'Search' %>
<% end %>

</div>
</div>
27 changes: 27 additions & 0 deletions app/views/articles/new.html.erb
@@ -0,0 +1,27 @@
<div class="articles">
<div class="containers">
<!--For each article, have user-fillable title, content, author and date fields - then create form once user clicks create-->
<%= form_for(@article) do |f| %>
<div class="field">
<%= f.label :title %><br>
<%= f.text_area :title %>
</div>
<div class="field">
<%= f.label :content %><br>
<%= f.text_area :content %>
</div>
<div class="field">
<%= f.label :author %><br>
<%= f.text_area :author %>
</div>
<div class="field">
<%= f.label :date %><br>
<%= f.date_field :date, value: Date.today %>
</div>
<div class="actions">
<%= f.submit "Create" %>
</div>
<% end %>

</div>
</div>
12 changes: 12 additions & 0 deletions app/views/articles/show.html.erb
@@ -0,0 +1,12 @@
<div class="articles">
<div class="containers">
<!--For selected article (to delete), show them + have option at end to delete-->
<%= form_for(@article) do |f| %>
<div class="field"> <%= f.label :title %><br>
<%= f.text_area :title %> </div>
<div class="actions">
<%= f.submit "Delete" %>
</div>
<% end %>
</div>
</div>
20 changes: 20 additions & 0 deletions config/routes.rb
@@ -1,4 +1,24 @@
Rails.application.routes.draw do
resources :articles # Sett all necessary functions for articles

root 'articles#index' # Set index function as root

get 'articles/count', to: 'articles#count'

# get 'articles/new', to: 'articles#new'
# post 'articles', to: 'articles#create'

# get 'articles/:id/edit', to: 'articles#edit', as: 'edit_article_by_id'
# patch 'articles/:id', to: 'articles#update' - UNCOMMENT THIS

get 'articles/search', to: 'articles#index', as: 'search_articles'

get 'articles/:id', to: 'articles#show'

# get 'articles/search', to: 'articles#search'

# delete 'articles', to: 'articles#destroy'
# delete 'articles/:id', to: 'articles#destroy'
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
Expand Down