Skip to content

Commit

Permalink
create the "more" nav menu
Browse files Browse the repository at this point in the history
  • Loading branch information
andymeneely committed Apr 30, 2020
1 parent 771a836 commit 54dc897
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 103 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ $dropdownmenu-arrows: true;
$dropdownmenu-arrow-color: $anchor-color;
$dropdownmenu-arrow-size: 6px;
$dropdownmenu-arrow-padding: 1.5rem;
$dropdownmenu-min-width: 200px;
$dropdownmenu-min-width: 150px;
$dropdownmenu-background: $white;
$dropdownmenu-submenu-background: $dropdownmenu-background;
$dropdownmenu-padding: $global-menu-padding;
Expand Down
Empty file.
Empty file.
34 changes: 0 additions & 34 deletions app/controllers/about_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,6 @@ class AboutController < ApplicationController

# GET /about
def index
@projects = Project.all
end

# GET /api/about/progress
def progress
stats = {}
Project.all.each do |p|
p_stats = {}
num_vulns = Vulnerability.where(project: p).count
p_stats[:num_vulns] = num_vulns
p_stats[:num_vulns_report] = ActiveSupport::NumberHelper.number_to_delimited(num_vulns, :delimiter => ',')
num_curated = Vulnerability.curated.where(project: p).count
p_stats[:num_curated] = num_curated
p_stats[:perc_curated] = 100.0 * num_curated / num_vulns.to_f
p_stats[:perc_report] = "%.1f%%" % p_stats[:perc_curated]
num_w_fixes = Fix.select(:vulnerability_id).distinct.count
p_stats[:perc_fixes] = (100.0 * num_w_fixes / num_vulns.to_f)
# @fix_report = "%.1f%%" % @perc_fixes
# @num_vccs = Vcc.count
# @num_w_vccs = Vcc.select(:vulnerability_id).distinct.count
# @perc_vccs = (100.0 * @num_w_vccs / num_vulns.to_f)
# @vcc_report = "%.1f%%" % @perc_vccs
stats[p.id] = p_stats
end
stats[0] = all_project_stats()
render_json_for_api stats
end

private

def all_project_stats
{
num_vulns: Vulnerability.count
}
end


Expand Down
42 changes: 42 additions & 0 deletions app/controllers/progress_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class ProgressController < ApplicationController

# GET /about
def index
@projects = Project.all
end

# GET /api/about/progress
def progress
stats = {}
Project.all.each do |p|
p_stats = {}
num_vulns = Vulnerability.where(project: p).count
p_stats[:num_vulns] = num_vulns
p_stats[:num_vulns_report] = ActiveSupport::NumberHelper.number_to_delimited(num_vulns, :delimiter => ',')
num_curated = Vulnerability.curated.where(project: p).count
p_stats[:num_curated] = num_curated
p_stats[:perc_curated] = 100.0 * num_curated / num_vulns.to_f
p_stats[:perc_report] = "%.1f%%" % p_stats[:perc_curated]
num_w_fixes = Fix.select(:vulnerability_id).distinct.count
p_stats[:perc_fixes] = (100.0 * num_w_fixes / num_vulns.to_f)
# @fix_report = "%.1f%%" % @perc_fixes
# @num_vccs = Vcc.count
# @num_w_vccs = Vcc.select(:vulnerability_id).distinct.count
# @perc_vccs = (100.0 * @num_w_vccs / num_vulns.to_f)
# @vcc_report = "%.1f%%" % @perc_vccs
stats[p.id] = p_stats
end
stats[0] = all_project_stats()
render_json_for_api stats
end

private

def all_project_stats
{
num_vulns: Vulnerability.count
}
end


end
2 changes: 1 addition & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def releases
private
# Use callbacks to share common setup or constraints between actions.
def set_project
@project = Project.find(params[:project_id])
@project = Project.find(params[:project_id])
end

# Never trust parameters from the scary internet, only allow the white list through.
Expand Down
15 changes: 0 additions & 15 deletions app/views/about/_howto.html.erb

This file was deleted.

42 changes: 2 additions & 40 deletions app/views/about/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,41 +1,3 @@
<%= render('shared/title') do %>
Data Curation
<% end %>
<h1>About Us</h1>

<%= render('shared/grid', size: 8) do %>
<p>
This project relies upon a massive effort to collect, correct, and annotate vulnerability history data. We call this process <b>curating</b>.
</p>

<ul class="tabs"
id="curate-tabs"
data-tabs
data-deep-link="true"
data-update-history="true"
data-deep-link-smudge="true"
data-deep-link-smudge-delay="500">
<li class="tabs-title is-active">
<a href="#howto" draggable="false">
<i class="vhp-icon-curate"></i>
How to Curate
</a>
</li>
<li class="tabs-title">
<a href="#progress" aria-selected="true" draggable="false">
<i class="vhp-icon-graph-pie"></i>
Progress
</a>
</li>
</ul>
<% end %>

<div data-tabs-content="curate-tabs">
<div class="tabs-panel is-active" id="howto">
<%= render 'howto' %>
</div>
<div class="tabs-panel" id="progress">
<%= render 'progress' %>
</div>
</div>

<%= javascript_include_tag "about" %>
<p>Stuff about us.</p>
25 changes: 16 additions & 9 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,24 @@
<li class="has-submenu is-dropdown-submenu-parent">
<a href="#">Tags</a>
<ul class="submenu menu" data-submenu>
<li><a href="/tags">All</a></li>
<li><a href="/tags?search=Project:">Projects</a></li>
<li><a href="/tags?search=CWE">CWEs</a></li>
<li><a href="/tags?search=Language">Languages</a></li>
<li><a href="/tags?search=Lesson">Lessons</a></li>
<li><a href="/tags?search=Severity:">Severities</a></li>
<li><a href="/tags?search=Subsystem">Subsystems</a></li>
<li class="center"><a href="/tags">All</a></li>
<li class="center"><a href="/tags?search=Project:">Projects</a></li>
<li class="center"><a href="/tags?search=CWE">CWEs</a></li>
<li class="center"><a href="/tags?search=Language">Languages</a></li>
<li class="center"><a href="/tags?search=Lesson">Lessons</a></li>
<li class="center"><a href="/tags?search=Severity:">Severities</a></li>
<li class="center"><a href="/tags?search=Subsystem">Subsystems</a></li>
</ul>
</li>
<li class="has-submenu is-dropdown-submenu-parent">
<a href="#">More</a>
<ul class="submenu menu" data-submenu>
<li><a href="/projects">Case Studies</a></li>
<li><a href="/progress">Progress</a></li>
<li><a href="/curate">How to Curate</a></li>
<li><a href="/about">About Us</a></li>
</ul>
</li>
<li class="right"><%= link_to "Curate", :controller =>'curate' %></li>
<li class="right"><a href="/about">About</a></li>
</ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>VHP Progress</h1>
<%= render('shared/grid', size: 8) do %>

<button class="button project-select-button" type="button"
Expand Down
19 changes: 19 additions & 0 deletions app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="row">
<h1>Case Study Projects</h1>

<p>TODO: make this better.</p>

<% Project.all.each do |p| %>
<div class="project-logo">
<a href="/tags/project-<%= p.subdomain %>">
<span style= "height:2em; width:2em;"
class="<%= p.subdomain %>-inline-logo"></span>
</a>
</div>
<div id="project-details"
class="project-details"
style="background-color:<%=p.bg_color %>">
<span> <%= p.name %></span>
</div>
<% end %>
</div>
2 changes: 2 additions & 0 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Project Show Page</h1>
Under construction.
6 changes: 4 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
resources :filepaths, only: [:index, :show], via: [:get], format: false,
param: :filepath_id

get :curate, to: 'curate#index'
resources :projects, only: [:index, :show], format: false, param: :project_id

get :progress, to: 'progress#index', format: false
get :curate, to: 'curate#index', format: false
get :about, to: 'about#index', format: false

scope :api do
Expand Down Expand Up @@ -47,7 +49,7 @@

resources :articles, only: [:index, :show], :format => false

resources :projects, only: [:index, :show], :format => false do
resources :projects, only: [:index, :show], :format => false, param: :project_id do
get :releases
end
end
Expand Down

0 comments on commit 54dc897

Please sign in to comment.