-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from tatiananantes/Album
Album
- Loading branch information
Showing
51 changed files
with
166 additions
and
17 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
// Place all the styles related to the Albums controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://sass-lang.com/ | ||
.modal { | ||
.modal-body { | ||
.img-thumbnail { | ||
width: 100%; | ||
background: transparent; | ||
padding: 0; | ||
border: 0; | ||
} | ||
} | ||
} | ||
|
||
.albums { | ||
img { | ||
margin-top: 20px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
class PhotosController < ApplicationController | ||
before_action :find_user | ||
before_action :find_album | ||
|
||
|
||
def new | ||
@photo = Photo.new | ||
end | ||
|
||
def create | ||
|
||
@photo = @album.photos.create(photo_params.merge(user_id: @user.id, album_id: @album.id)) | ||
redirect_to user_album_path(@user, @album) | ||
end | ||
|
||
|
||
private | ||
|
||
def photo_params | ||
params.require(:photo).permit(:image) | ||
end | ||
|
||
def find_user | ||
@user = User.find_by_id(params[:user_id]) | ||
end | ||
|
||
def find_album | ||
@album = @user.albums.find_by_id(params[:album_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
<% @user.albums.reverse.each do |album| %> | ||
<p><%= album.name%></p> | ||
<%end%> | ||
<p> | ||
<a href="/users/<%=@user.id%>/albums/<%=album.id%>"> | ||
<%= album.name %> | ||
</a> | ||
</p> | ||
<%end%> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
<%=@album.name%> | ||
<h1><%= @album.name %></h1> | ||
|
||
This is an album | ||
|
||
<% if @user.id == session[:user_id]%> | ||
<div class="text-right"> | ||
<%= link_to "Add new photo to album", new_user_album_photo_path(@user, @album), :class => "btn btn-primary"%> | ||
</div> | ||
<%end%> | ||
|
||
<div class= "row albums"> | ||
<% @album.photos.reverse.each do |photo| %> | ||
<div class="col-sm-3"> | ||
<a href="#" type="button" data-bs-toggle="modal" data-bs-target="#exampleModal"> | ||
<%= image_tag photo.image.variant(resize_to_limit: [600, 600]), class: "img-fluid img-thumbnail" %> | ||
</a> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<!-- Modal --> | ||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-body text-center"> | ||
|
||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
var exampleModal = document.getElementById('exampleModal') | ||
exampleModal.addEventListener('show.bs.modal', function (event) { | ||
// Button that triggered the modal | ||
var button = event.relatedTarget; | ||
// Extract info from data-bs-* attributes | ||
var recipient = button.innerHTML; | ||
// If necessary, you could initiate an AJAX request here | ||
// and then do the updating in a callback. | ||
// | ||
// Update the modal's content. | ||
var modalBody = exampleModal.querySelector('.modal-body'); | ||
|
||
modalBody.innerHTML = recipient; | ||
}) | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,4 @@ | |
</div> | ||
</div> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="center-block"> | ||
<div class="form-group-wrap"> | ||
|
||
<%= form_with model: [ @user, @album, @album.photos.build ], local: true do |form| %> | ||
|
||
<div class="form-group"> | ||
<%= form.label :image, class: "control-label"%> | ||
<%= form.file_field :image, class:"form-control", required: "true" %> | ||
</div> | ||
<div class="form-group"> | ||
<%= form.submit "Create!", class: "btn btn-primary" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+53.7 KB
...z0ax86um2f1ndmf2dmjf41pp/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+2.87 KB
...z0ax86um2f1ndmf2dmjf41pp/56d9d0c7d9e49774f5a2454a68509528362f200c97164b674550e4f2830e3151
Binary file not shown.
Binary file added
BIN
+18.2 KB
...w035n9togu8062z31f92uh44/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+18.2 KB
...eb2ovx5vlwe4hxy4d24wbr4a/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+67.3 KB
...jzklcuxk90ckwcqv9rf886sy/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+14 KB
...m7db4eq49kne1htiexe9ee7g/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+69.8 KB
...0olko4lxx2x5x7x37ponefdx/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+18.4 KB
...0olko4lxx2x5x7x37ponefdx/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+10.9 KB
...upjlhjcp5ybsmvtcbkihhd84/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+4.21 KB
...day37bcvvymkfbbumag72hvm/56d9d0c7d9e49774f5a2454a68509528362f200c97164b674550e4f2830e3151
Binary file not shown.
Binary file added
BIN
+13.1 KB
...day37bcvvymkfbbumag72hvm/d22d29d38393e844509e519a81db9789797c225b8eb8c334d9120bab21401b01
Binary file not shown.
Binary file added
BIN
+70.2 KB
...fvkju6el6neys085fq6piw4k/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+2.69 KB
...fvkju6el6neys085fq6piw4k/56d9d0c7d9e49774f5a2454a68509528362f200c97164b674550e4f2830e3151
Binary file not shown.
Binary file added
BIN
+53.7 KB
...qljgriomj2hn8tq7bus0q9k1/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+2.87 KB
...qljgriomj2hn8tq7bus0q9k1/56d9d0c7d9e49774f5a2454a68509528362f200c97164b674550e4f2830e3151
Binary file not shown.
Binary file added
BIN
+53.7 KB
...qvablgmw29eosw84nt2wyxnj/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+16.3 KB
...qvablgmw29eosw84nt2wyxnj/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+26.3 KB
...4a80ys1h981xtjbqtazfaa5b/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+2.05 KB
...4a80ys1h981xtjbqtazfaa5b/56d9d0c7d9e49774f5a2454a68509528362f200c97164b674550e4f2830e3151
Binary file not shown.
Binary file added
BIN
+18.2 KB
...zh8yha2b3tyx37z0rc9oywyg/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+14 KB
...u4b67yq02plqghehoj6e0ra8/eebe8c804ad0baac89479dd4a8484c7da8b1c0c80dc361d277ea837f4c72817b
Binary file not shown.
Binary file added
BIN
+86.1 KB
...utupoh0xrq4rsdlogk8jac1u/2e07992f45e78d264cb0d0832f9e86f34f2931716c6382e51b27cab3807be98f
Binary file not shown.
Binary file added
BIN
+4.21 KB
...utupoh0xrq4rsdlogk8jac1u/56d9d0c7d9e49774f5a2454a68509528362f200c97164b674550e4f2830e3151
Binary file not shown.
Binary file not shown.