Research tab ported

This commit is contained in:
Oliver Kennedy 2016-05-25 16:58:50 -04:00
parent 1096beedcc
commit eb54738b80
175 changed files with 332 additions and 107 deletions

View file

@ -11,24 +11,40 @@ LabMetadata::build_people_metadata()
site :odin_lab, out: "build" do
## Splice off header information
for_files(/((\.erb)|(\.md)|(\.html))$/) do
activate extract_headers
end
## Render specialized formats
for_files(/\.md$/) do
activate render_markdown
end
for_files(/\.erb$/) do
activate render_erb
end
## Generate pages for each lab member
LabMetadata::create_people_pages
for_files(/people\/.*\.html$/) do
exclude_files(/index\.html/) do
activate apply_template("templates/person.erb")
end
end
## Apply templating
for_files(/\.html$/) do
activate apply_template("templates/lab.erb")
end
## Specify specialized dependencies (e.g., on the database)
for_files(/people\/.*\.html$/) do
add_dependency "db/lab.json"
end
## Static assets
add_assets([
"bootstrap", "odin.css", "jquery.js", "logos"
"bootstrap", "odin.css", "jquery.js", "logos", "favicon", "people"
])
end

View file

Before

Width:  |  Height:  |  Size: 353 KiB

After

Width:  |  Height:  |  Size: 353 KiB

View file

@ -1,5 +1,6 @@
body {
padding-top: 50px;
padding-bottom: 30px;
text-align: justify;
}
.starter-template {
@ -15,7 +16,9 @@ body {
color: black;
}
.person_list h1 {
margin-bottom: 20px;
}
.person_list .person {
margin-top: 5px;
margin-bottom: 7px;
@ -39,3 +42,71 @@ body {
.person_list a {
text-decoration: none;
}
.person .project_list {
text-align: center;
font-size: 12px;
color: #041a9b;
}
.person img.photo {
float: right;
border: solid 2px gray;
margin-right: 50px;
margin-left: 30px;
margin-bottom: 30px;
}
.person .paper_list {
margin-left: 10px;
margin-right: 10px;
}
.person .links {
text-align: left;
margin-bottom: 20px;
}
.person .links a {
font-size: 12px;
color: #041a9b;
margin-left: 10px;
margin-right: 10px;
text-decoration: none;
}
.paper_list ul {
padding-left: 20px;
padding-right: 20px;
}
.paper_list li {
margin-top: 20px;
margin-left: 0px;
margin-right: 0px;
font-size: 15px;
list-style-type: none;
line-height: 20px;
}
.paper_list li .title {
font-size: 17px;
font-weight: bold;
line-height: 22px;
}
.paper_list li .authors {
margin-left: 10px;
}
.paper_list li .authors .lab_member {
color: #041a9b;
font-weight: bold;
font-style: italic;
}
.paper_list li .metadata {
margin-left: 10px;
}

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -56,7 +56,7 @@
"urls" : {
"paper" : "http://odin.cse.buffalo.edu/papers/2016/ERMIS-final.pdf"
},
"projects" : ["insiderthreats"]
"projects" : ["insider-threats"]
},
{ "title":"Pocket Data: The Need for TPC-MOBILE",
"authors":[

View file

@ -20,23 +20,23 @@ module GemSmith
}
end
def load_site(in_path, out_path, out_root)
def load_site(in_path, out_path)
if File.symlink? in_path then
$stderr.puts "Warning: Skipping symlink #{f}"
[]
elsif File.directory? in_path then
full_out_dir = File.join(out_root, out_path)
full_out_dir = File.join($gemsmith[:out_path], out_path)
directory "#{full_out_dir}" => [File.dirname("#{full_out_dir}")]
Dir["#{in_path}/*"].map do |f|
out_f = File.join(out_path, File.basename(f))
load_site(f, out_f, out_root)
load_site(f, out_f)
end.flatten(1)
else
[{
modified: File.mtime(in_path),
in_path: in_path,
dependencies: [in_path, File.dirname(File.join(out_root, out_path))],
out_path: File.join(out_root, out_path),
dependencies: [in_path, File.dirname(File.join($gemsmith[:out_path], out_path))],
out_path: out_path,
rel_dir: File.dirname(out_path),
stream: Pipeline.new(in_path)
}]
@ -46,7 +46,15 @@ module GemSmith
def for_files(pattern)
tmp = $gemsmith[:active]
$gemsmith[:active] =
$gemsmith[:active].where {|f| pattern =~ File.basename(f[:out_path]) }
$gemsmith[:active].where {|f| pattern =~ f[:out_path] }
yield
$gemsmith[:active] = tmp
end
def exclude_files(pattern)
tmp = $gemsmith[:active]
$gemsmith[:active] =
$gemsmith[:active].where {|f| not pattern =~ f[:out_path] }
yield
$gemsmith[:active] = tmp
end
@ -60,7 +68,7 @@ module GemSmith
$gemsmith[:in_path] = in_path
$gemsmith[:out_path] = out_path
$gemsmith[:active] = load_site(in_path, "", out_path)
$gemsmith[:active] = load_site(in_path, "")
directory out_path
@ -69,9 +77,9 @@ module GemSmith
yield
$gemsmith[:active].each { |f|
file f[:out_path] => f[:dependencies] do
file File.join(out_path, f[:out_path]) => f[:dependencies] do
error = nil;
File.open(f[:out_path], "w+") { |out|
File.open(File.join(out_path, f[:out_path]), "w+") { |out|
begin
f[:stream].pipe_to(out)
rescue => e
@ -79,11 +87,11 @@ module GemSmith
end
}
unless error.nil?
File.unlink(f[:out_path])
File.unlink(File.join(out_path, f[:out_path]))
raise error
end
end
task site_name => f[:out_path]
task site_name => File.join(out_path, f[:out_path])
}
end
@ -161,20 +169,41 @@ module GemSmith
in_dir = params.fetch(:source, "assets")
out_dir = params.fetch(:dir, "assets")
assets.each { |a|
$gemsmith[:active] += load_site(File.join(in_dir, a), File.join(out_dir, a), $gemsmith[:out_path])
$gemsmith[:active] += load_site(File.join(in_dir, a), File.join(out_dir, a))
$gemsmith[:assets][a] = File.join(out_dir, a)
}
end
def root_path
context = File.split($gemsmith[:now_rendering])
def add_file_string(out_path, data)
$gemsmith[:active].push({
dependencies: [],
out_path: out_path,
rel_dir: File.dirname(out_path),
stream: Pipeline.new(string: data)
})
end
def root_path(file = nil)
context = $gemsmith[:now_rendering].split(/#{File::SEPARATOR}/)
context.pop
File.join( *([".."] * context.length) )
context.shift if context[0] == ""
return file if context.empty?
ret = File.join( *([".."] * context.length))
return File.join(ret, file) unless file.nil?
return ret
end
def asset_path(asset)
target = $gemsmith[:assets][asset]
return "???" if target.nil?
File.join( root_path, target )
root_path(target)
end
def all_outputs
$gemsmith[:active].map { |x| x[:out_path] }
end
def metadata_for(path)
$gemsmith[:active].find { |x| x[:out_path] == path }
end
end

View file

@ -7,10 +7,45 @@ module LabMetadata
members.each do |name, data|
data["link_relative"] = not(data.has_key? "link")
data["name"] = name
page = "/people/#{name.downcase.gsub(/ /, "_").gsub(/[^a-z0-9A-Z_]/, "")}.html"
unless data.has_key? "link"
data["link"] = "people/#{name.downcase.gsub(/ /, "_").gsub(/[^a-z0-9A-Z_]/, "")}.html"
data["link"] = page
end
data["page"] = page
end
end
def LabMetadata.create_people_pages
known_pages =
GemSmith::all_outputs.
delete_if { |x| not /people\/.*\.html$/ =~ x }
$db["lab/members"].each do |name, data|
unless known_pages.include? data["page"]
GemSmith::add_file_string(data["page"], "#{name} hasn't written anything yet.")
end
GemSmith::metadata_for(data["page"]).merge!({
title: name,
name: name
}.merge(data))
end
end
def LabMetadata.link_for(person)
data = $db["lab/members"][person]
if data.nil? then person else "<a class=\"lab_member\" href=\"#{GemSmith::root_path(data["link"])}\">#{person}</a>" end
end
def LabMetadata.publications_for(person)
$db["publications"].
where { |pub| pub["authors"].include? person }
end
def LabMetadata.members_on_project(project)
$db["lab/members"].values.
where { |m| m.fetch("projects", []).include? project }.
map { |m| m["name"] }
end
end

View file

@ -1,6 +1,20 @@
class Pipeline
def initialize(file)
@op = lambda { |nxt| File.open(file) { |fp| nxt.call(fp) }}
def initialize(source)
source = { file:source } unless source.is_a? Hash
if source.has_key? :file
@op = lambda { |nxt| File.open(source[:file]) { |fp| nxt.call(fp) }}
elsif source.has_key? :string
data = source[:string]
@op = lambda { |nxt|
IO.pipe { |r, w|
w.write(data)
w.close_write
nxt.call(r)
}
}
end
end
def transform(&transformation)

View file

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Some files were not shown because too many files have changed in this diff Show more