Skip to content

Commit

Permalink
removing datatables + loading google charts once + better cards
Browse files Browse the repository at this point in the history
  • Loading branch information
sic2 committed Jul 16, 2016
1 parent 4d070d9 commit fd97e72
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 111 deletions.
1 change: 0 additions & 1 deletion webapp/app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
*/
@import "bootstrap";
@import "https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap4.min.css";
@import "typeaheadjs.scss";
@import "font-awesome";
@import "introjs";
Expand Down
2 changes: 1 addition & 1 deletion webapp/app/controllers/profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def index
# GET /users/:id
def show
set_user
@posts = Post.where(author_uid: @user.uid).limit(10).order('created_at desc')
@posts = Post.where(author_uid: @user.uid).limit(30).order('created_at desc')
end

def new
Expand Down
9 changes: 1 addition & 8 deletions webapp/app/views/events/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@

<script>
$(document).ready(function(){
initTypeahead('/events/typeahead', '/events/');

// $('#table-events').DataTable({
// ordering: false,
// autoWidth: false,
// "language": { "search": "Advanced Search: "}
// });

initTypeahead('/events/typeahead', '/events/');
});

</script>
Expand Down
47 changes: 30 additions & 17 deletions webapp/app/views/home/_card.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
<div class='post card-block'>
<blockquote class="card-blockquote custom-overflow">
<% if post.content != nil %>
<p><%= post.content[0, 50] %> ...</p>
<p><%= post.content[0, 20] %> ...</p>
<% end %>
</blockquote>
<div class="row">
<div class="col-xs-6">
<% if post.link.present? %>
<% if post.link.present? and (post.post_type.eql? 'link' or post.post_type.eql? 'event') %>
<%= link_to post.link, :target => "_blank" do %>
<% if post.post_type.eql? 'event' %>
<i class="fa fa-calendar" ></i>
<% elsif post.post_type.eql? 'photo' %>
<i class="fa fa-photo" ></i>
<% if post.post_type.eql? 'link' %>
<i class="fa fa-link"></i>
<% else %>
<i class="fa fa-link" ></i>
<i class="fa fa-calendar"></i>
<% end %>
<% end %>
<% else %>
<% if post.post_type.eql? 'photo' %>
<i class="fa fa-photo"></i>
<% else %>
<i class="fa fa-sticky-note-o"></i>
<% end %>
<% end %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% unless post.post_type.eql? 'event' %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% end %>
<% end %>
</div>
<div class="col-xs-6 text-xs-right">
Expand All @@ -41,19 +48,25 @@
<div class="modal-content">
<div class="modal-header">
<div class="col-xs-6 text-xs-left">
<% if post.link.present? %>
<% if post.link.present? and (post.post_type.eql? 'link' or post.post_type.eql? 'event') %>
<%= link_to post.link, :target => "_blank" do %>
<% if post.post_type.eql? 'event' %>
<i class="fa fa-calendar" ></i>
<% elsif post.post_type.eql? 'photo' %>
<i class="fa fa-photo" ></i>
<% if post.post_type.eql? 'link' %>
<i class="fa fa-link"></i>
<% else %>
<i class="fa fa-link" ></i>
<i class="fa fa-calendar"></i>
<% end %>
<% end %>
<% else %>
<% if post.post_type.eql? 'photo' %>
<i class="fa fa-photo"></i>
<% else %>
<i class="fa fa-sticky-note-o"></i>
<% end %>
<% end %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% unless post.post_type.eql? 'event' %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% end %>
<% end %>
</div>
<div class="col-xs-6 text-xs-right">
Expand Down
10 changes: 5 additions & 5 deletions webapp/app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<!-- <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> -->
<script type="text/javascript">

// Load the Visualization API and the corechart package.
google.charts.load('current', {
'packages': ['corechart', 'controls']
});
// // Load the Visualization API and the corechart package.
// google.charts.load('current', {
// 'packages': ['corechart', 'controls']
// });

// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
Expand Down
121 changes: 66 additions & 55 deletions webapp/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<!-- Must include datatables explicitly for bootstrap 4 - gems not available yet -->
<%= javascript_include_tag "https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"%>
<%= javascript_include_tag "https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap4.min.js" %>
<%= csrf_meta_tags %>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">

// Load the Visualization API and the corechart package.
google.charts.load('current', {
'packages': ['corechart', 'controls']
});
</script>
</head>
<body>
<!-- Do not display alerts by default
Expand All @@ -20,64 +25,70 @@
<br>

<nav class="navbar navbar-fixed-top" style="background-color: #4DB6AC;">

<div class="container">
<%= link_to 'Isamuni', home_index_path, {class: "navbar-brand"} %>
<ul class="nav navbar-nav">
<% if current_user %>
<li class="nav-item btn-group">
<a class="dropdown-toggle nav-link" type="button" id="dropdownMenuUser" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-user"></i> Account
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuUser">
<%= link_to current_user.first_name, edit_user_path, class: "dropdown-item" %>
<%= link_to "Le mie pagine", pages_path, class: "dropdown-item" %>
<%= link_to signout_path, id: "sign_out", class: "dropdown-item" do %>
<i class="fa fa-sign-out"></i> Log Out
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#collapsingNavbar">
&#9776;
</button>
<div class="collapse navbar-toggleable-xs" id="collapsingNavbar">
<%= link_to 'Isamuni', home_index_path, {class: "navbar-brand"} %>
<ul class="nav navbar-nav">
<% if current_user %>
<li class="nav-item btn-group">
<a class="dropdown-toggle nav-link" type="button" id="dropdownMenuUser" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-user"></i> Account
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuUser">
<%= link_to current_user.first_name, edit_user_path, class: "dropdown-item" %>
<%= link_to "Le mie pagine", pages_path, class: "dropdown-item" %>
<%= link_to signout_path, id: "sign_out", class: "dropdown-item" do %>
<i class="fa fa-sign-out"></i> Log Out
<% end %>
</div>
</li>
<% else %>
<li class="nav-item">
<%= link_to "/auth/facebook", id: "sign_in", class: 'nav-link', data: {intro:'Login with Facebook to join Isamuni and create a personal profile'} do %>
<i class="fa fa-facebook"></i> Login
<% end %>
</div>
</li>
<% end %>
<li class="nav-item">
<%= link_to users_path, class: 'nav-link' do %>
<i class="fa fa-user-plus"></i>
<% end %>
</li>
<% else %>
<li class="nav-item">
<%= link_to "/auth/facebook", id: "sign_in", class: 'nav-link', data: {intro:'Login with Facebook to join Isamuni and create a personal profile'} do %>
<i class="fa fa-facebook"></i> Login
<%= link_to companies_path, class: 'nav-link' do %>
<i class="fa fa-industry"></i>
<% end %>
</li>
<% end %>
<li class="nav-item">
<%= link_to users_path, class: 'nav-link' do %>
<i class="fa fa-user-plus"></i>
<% end %>
</li>
<li class="nav-item">
<%= link_to companies_path, class: 'nav-link' do %>
<i class="fa fa-industry"></i>
<% end %>
</li>
<li class="nav-item">
<%= link_to communities_path, class: 'nav-link' do %>
<i class="fa fa-users"></i>
<% end %>
</li>

<li class="nav-item">
<%= link_to events_path, class: 'nav-link' do %>
<i class="fa fa-calendar"></i>
<% end %>
</li>
<li class="nav-item">
<%= link_to opendata_path, class: 'nav-link' do %>
<i class="fa fa-question-circle-o"></i>
<% end %>
</li>
<li class="nav-item">
<a class='nav-link' href="javascript:void(0);" onclick="javascript:introJs().setOption('showStepNumbers', false).start();">Tour</a>
</li>
</ul>
<form class="form-inline pull-xs-right" role="search">
<%= yield :search %>
</form>
<li class="nav-item">
<%= link_to communities_path, class: 'nav-link' do %>
<i class="fa fa-users"></i>
<% end %>
</li>

<li class="nav-item">
<%= link_to events_path, class: 'nav-link' do %>
<i class="fa fa-calendar"></i>
<% end %>
</li>
<li class="nav-item">
<%= link_to opendata_path, class: 'nav-link' do %>
<i class="fa fa-question-circle-o"></i>
<% end %>
</li>
<li class="nav-item">
<a class='nav-link' href="javascript:void(0);" onclick="javascript:introJs().setOption('showStepNumbers', false).start();">Tour</a>
</li>
</ul>
<form class="form-inline pull-xs-right" role="search">
<%= yield :search %>
</form>

<a href="https://github.com/sic2/isamuni"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>
<a href="https://github.com/sic2/isamuni"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>
</div>
</div>
</nav>

Expand Down
74 changes: 61 additions & 13 deletions webapp/app/views/profile/_card.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
<div class="post card-block">
<blockquote class="card-blockquote">
<div class='post card-block'>
<blockquote class="card-blockquote custom-overflow">
<% if post.content != nil %>
<p><%= post.content[0, 150] %> ...</p>
<p><%= post.content[0, 20] %> ...</p>
<% end %>
</blockquote>
<div class="row">
<div class="col-xs-6">
<% if post.link.present? %>
<% if post.link.present? and (post.post_type.eql? 'link' or post.post_type.eql? 'event') %>
<%= link_to post.link, :target => "_blank" do %>
<% if post.post_type.eql? 'event' %>
<i class="fa fa-calendar" ></i>
<% if post.post_type.eql? 'link' %>
<i class="fa fa-link"></i>
<% else %>
<i class="fa fa-link" ></i>
<i class="fa fa-calendar"></i>
<% end %>
<% end %>
<% else %>
<% if post.post_type.eql? 'photo' %>
<i class="fa fa-photo"></i>
<% else %>
<i class="fa fa-sticky-note-o"></i>
<% end %>
<% end %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% unless post.post_type.eql? 'event' %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% end %>
<% end %>
</div>
<div class="col-xs-6 text-xs-right">
<small style="color:black;"><%= post.author_name %></small>
<small style="color:black;"><%= post.author_name[0..0] + ". " + post.author_name.split.last %></small>
</div>
</div>
<div class="row">
Expand All @@ -30,17 +39,56 @@
<% end %>
</div>
<div class="col-xs-6 text-xs-right">
<small style="color:black;"><%= post.created_at.strftime("%Y-%m-%d %H:%M %Z") %></small>
<small style="color:black;"><%= post.created_at.strftime("%d-%m-%y") %></small>
</div>
</div>

<div class="modal fade" id=<%= post.uid %> tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="col-xs-6 text-xs-left">
<% if post.link.present? and (post.post_type.eql? 'link' or post.post_type.eql? 'event') %>
<%= link_to post.link, :target => "_blank" do %>
<% if post.post_type.eql? 'link' %>
<i class="fa fa-link"></i>
<% else %>
<i class="fa fa-calendar"></i>
<% end %>
<% end %>
<% else %>
<% if post.post_type.eql? 'photo' %>
<i class="fa fa-photo"></i>
<% else %>
<i class="fa fa-sticky-note-o"></i>
<% end %>
<% end %>
<% unless post.post_type.eql? 'event' %>
<%= link_to 'https://www.facebook.com/' + post.uid, :target => "_blank" do %>
<i class="fa fa-facebook" ></i>
<% end %>
<% end %>
</div>
<div class="col-xs-6 text-xs-right">
<small style="color:black;"><%= post.created_at.strftime("%d-%m-%y %H:%M %Z") %></small>
</div>
</div>
<div class="modal-body">
<%= post.content %>
<%= markdown(post.content) %>
<% if post.link != nil && post.picture != nil %>
<a href=<%= post.link %> target="_blank">
<img src=<%= post.picture %> class="center-block img-responsive img-rounded">
</a>
<% elsif post.picture != nil %>
<img src=<%= post.picture %> class="center-block img-responsive img-rounded">
<% end %>

</div>
<div class="modal-footer">
<div class="col-xs-6 text-xs-left">
<small style="color:black;">Posted by: <strong><%= post.author_name %></strong></small>
</div>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
Expand Down
Loading

0 comments on commit fd97e72

Please sign in to comment.