0

I need to add the following features to my existing code (posted below) in Rails using Jquery, JSON, Ruby and HTML. I have a lot of ideas and researched a bit but Itd be great if someone can help me with integrating them:

I need to add a feature to sign a url associated with each file in my table.Where the url is say a 'string1' + the prefix from <%= hidden_field_tag :prefix, @prefix %> I was thinking of using the 'aws_cf_signer' gem in rails and code such as : -

signer = AwsCfSigner.new('./private-key-file.pem')
url = signer.sign(url)

I need to replace/modify the form within the second 'td' element in the view code in RAILS below to allow the user options to create shortlinks with expiration dates for each url: (can be multiple for each file)

For this I am using the 'url_shortener' gem and code:

  authorize = UrlShortener::Authorize.new 'xxxxxxx', 'yyyyyyy' 

  client = UrlShortener::Client.new(authorize) 

My Approach:

for creating the expiration dates --- I would have the user input a date via a datepicker (using the Jquery-ui gem for rails).

JSON : for Serialization and Deserialization of Ruby objects --I would use an array of hashes named say 'links' and then use

JSON.generate(links) for serialization and 
 JSON.parse() for deserialization. 

I would loop through the array (get the original object).

MY CODE SO FAR:

I am using JQuery to display a corresponding hidden 'td' element (hidden using css ---> display:none) when a specific button is clicked by a user in a table.

Code for View:

<h2>Files</h2>
<table class="table">
<tr>
<th>Filename</th>
<th>Description</th>
<th>Download Link</th>
</tr>
<% @files.each do |file| %>
<% filename = file.split('/').last %>
<% object = @bucket.objects[file] %>

<tr>         
<td><%= filename %></td>  

<td>
<div class="file_description"><%= object.metadata['description']%>    
<button id     ="file3" type="button"  class= "btn btn-default   
  edit_description"   onclick="Window(this)">Edit</button>                      
 </div>
 <div id = file2 class="file_description_update" >
  <%= form_tag({:action => 'update_file_info'}, multipart: true) do %> 
    Update File Description: <%= text_area_tag :description %>
    <%= hidden_field_tag :s3_path, file %>  
    <%= hidden_field_tag :prefix, @prefix %>
    <%= submit_tag 'Submit' %> </td> <br />
  <% end %>
  </div>

  </td> 

  <td><%= link_to "Download", download_url_for(file) %></td>

  </tr>
  <% end %>
  </table>

Current JQuery code :

$(document).ready(function(){ 
$( "button.edit_description" ).on( "click", function( event ) { 
$(this).closest('td').find( "div.file_description_update" ).show(); 
}); 
 });

Id really appreciate if someone can help me with most parts of the above features!Can someone please guide me with code for this? Thanks

Edited by pritaeas: Moved to Ruby.

2
Contributors
1
Reply
19
Views
3 Years
Discussion Span
Last Post by LastMitch
0

Id really appreciate if someone can help me with most parts of the above features!Can someone please guide me with code for this?

@zack000smith

A lot of Daniweb members will have a hard time assisting with this because it's alot of work. You can't expect someone to guide you with this. Either you solve on your own or pay someone to do it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.