mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
add public site-wide green report
This commit is contained in:
parent
f2ec93a4d7
commit
dd5f0f20f0
@ -35,6 +35,31 @@ class MainController < ApplicationController
|
||||
def sascon
|
||||
end
|
||||
|
||||
def paper
|
||||
@navbar_color = '#4CAF50'
|
||||
|
||||
@total_notebook_pages = 0
|
||||
@total_pages_equivalent = 0
|
||||
@total_trees_saved = 0
|
||||
|
||||
@per_page_savings = {}
|
||||
|
||||
(Rails.application.config.content_types[:all] + [Timeline, Document]).each do |content_type|
|
||||
physical_page_equivalent = GreenService.total_physical_pages_equivalent(content_type)
|
||||
tree_equivalent = physical_page_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE
|
||||
|
||||
@per_page_savings[content_type.name] = {
|
||||
digital: content_type.last.try(:id) || 0,
|
||||
pages: physical_page_equivalent,
|
||||
trees: tree_equivalent
|
||||
}
|
||||
|
||||
@total_notebook_pages += @per_page_savings.dig(content_type.name, :digital)
|
||||
@total_pages_equivalent += @per_page_savings.dig(content_type.name, :pages)
|
||||
@total_trees_saved += @per_page_savings.dig(content_type.name, :trees)
|
||||
end
|
||||
end
|
||||
|
||||
def prompts
|
||||
@sidenav_expansion = 'writing'
|
||||
@navbar_color = '#FF9800'
|
||||
|
||||
@ -45,10 +45,21 @@ class GreenService < Service
|
||||
end
|
||||
|
||||
def self.total_document_pages_equivalent
|
||||
(Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round
|
||||
(Document.with_deleted.where.not(body: ["", nil]).sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).round
|
||||
end
|
||||
|
||||
def self.total_timeline_pages_equivalent
|
||||
(TimelineEvent.last.id / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i
|
||||
end
|
||||
|
||||
def self.total_physical_pages_equivalent(content_type)
|
||||
case content_type.name
|
||||
when 'Timeline'
|
||||
GreenService.total_timeline_pages_equivalent
|
||||
when 'Document'
|
||||
GreenService.total_document_pages_equivalent
|
||||
else
|
||||
GreenService.physical_pages_equivalent_for(content_type.name) * (content_type.last.try(:id) || 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -122,7 +122,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% Rails.application.config.content_type_names[:all].each do |content_type| %>
|
||||
<% (Rails.application.config.content_type_names[:all] + ["Timeline", "Document"]).each do |content_type| %>
|
||||
<%
|
||||
content_list_count = content_class_from_name(content_type).last.try(:id) || 0
|
||||
|
||||
|
||||
126
app/views/main/paper.html.erb
Normal file
126
app/views/main/paper.html.erb
Normal file
@ -0,0 +1,126 @@
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<%=
|
||||
image_tag 'tristan/small.png', class: 'right hide-on-small-only', style: 'margin-left: 2em'
|
||||
%>
|
||||
|
||||
<div class="card-title green-text text-darken-2">Going digital saves paper and trees!</div>
|
||||
<br />
|
||||
<p>
|
||||
It's well-known that Notebook.ai offers a wide variety of features that just aren't
|
||||
possible with traditional paper notebooks. However, those aren't the only benefits of
|
||||
going digital!
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
Whether you're worldbuilding with our specialized notebook pages, outlining story
|
||||
timelines, or writing your next novel, every page you create in Notebook.ai directly
|
||||
contributes to less paper being used — and fewer trees cut down!
|
||||
</p>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m12 l4">
|
||||
<div class="card-panel center green white-text">
|
||||
<h1 style="margin: 0"><%= number_with_delimiter @total_notebook_pages %></h1>
|
||||
digital ideas stored
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m12 l4">
|
||||
<div class="card-panel center green white-text">
|
||||
<h1 style="margin: 0"><%= number_with_delimiter @total_pages_equivalent %></h1>
|
||||
equivalent physical pages
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m12 l4">
|
||||
<div class="card-panel center green white-text">
|
||||
<i class="material-icons left large">park</i>
|
||||
<h1 style="margin: 0"><%= number_with_delimiter @total_trees_saved.round %></h1>
|
||||
trees saved
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m12 l8 offset-l4">
|
||||
<div class="card-panelf">
|
||||
<p class="grey-text text-darken-1">
|
||||
<i class="material-icons left green-text">park</i>
|
||||
Note: The average 40-foot pine tree typically yields between 10,000 and 20,000 notebook-quality sheets of paper.
|
||||
For the estimations on this page, we're using a conservative estimate of
|
||||
<%= number_with_delimiter GreenService::SHEETS_OF_PAPER_PER_TREE %> pages per tree.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="card-title">Our community paper footprint</div>
|
||||
<!-- good place for a little bit of copy -->
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Digital content</th>
|
||||
<th>Equivalent physical pages</th>
|
||||
<th>Equivalent trees</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% (Rails.application.config.content_type_names[:all] + ["Timeline", "Document"]).each do |content_type| %>
|
||||
<%
|
||||
content_list_count = @per_page_savings.dig(content_type, :digital)
|
||||
physical_page_equivalent = @per_page_savings.dig(content_type, :pages)
|
||||
tree_equivalent = @per_page_savings.dig(content_type, :trees)
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
<i class="material-icons left <%= content_class_from_name(content_type).color %>-text">
|
||||
<%= content_class_from_name(content_type).icon %>
|
||||
</i>
|
||||
<%= number_with_delimiter content_list_count %>
|
||||
<%= content_type.pluralize content_list_count %>
|
||||
</td>
|
||||
<td>
|
||||
<i class="material-icons left grey-text">copy_all</i>
|
||||
<%= number_with_delimiter physical_page_equivalent %>
|
||||
<%= 'page'.pluralize physical_page_equivalent %>
|
||||
</td>
|
||||
<td>
|
||||
<i class="material-icons left green-text">park</i>
|
||||
<%= number_with_delimiter tree_equivalent.round(5) %>
|
||||
<%= 'tree'.pluralize tree_equivalent %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td>Totals</td>
|
||||
<td>
|
||||
<strong>
|
||||
<i class="material-icons left grey-text">copy_all</i>
|
||||
<%= number_with_delimiter @total_pages_equivalent %>
|
||||
<%= 'page'.pluralize @total_pages_equivalent %>
|
||||
</strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong>
|
||||
<i class="material-icons left green-text">park</i>
|
||||
<%= number_with_delimiter @total_trees_saved.round(5) %>
|
||||
<%= 'tree'.pluralize @total_trees_saved %>
|
||||
saved
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
notebook paper link
|
||||
@ -168,6 +168,7 @@ Rails.application.routes.draw do
|
||||
|
||||
# Info pages
|
||||
scope '/about' do
|
||||
get '/paper', to: 'main#paper', as: :green_paper
|
||||
get '/privacy', to: 'main#privacyinfo', as: :privacy_policy
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user