Research tab ported
This commit is contained in:
parent
1096beedcc
commit
eb54738b80
18
Rakefile
18
Rakefile
|
@ -11,24 +11,40 @@ LabMetadata::build_people_metadata()
|
||||||
|
|
||||||
site :odin_lab, out: "build" do
|
site :odin_lab, out: "build" do
|
||||||
|
|
||||||
|
## Splice off header information
|
||||||
for_files(/((\.erb)|(\.md)|(\.html))$/) do
|
for_files(/((\.erb)|(\.md)|(\.html))$/) do
|
||||||
activate extract_headers
|
activate extract_headers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## Render specialized formats
|
||||||
for_files(/\.md$/) do
|
for_files(/\.md$/) do
|
||||||
activate render_markdown
|
activate render_markdown
|
||||||
end
|
end
|
||||||
for_files(/\.erb$/) do
|
for_files(/\.erb$/) do
|
||||||
activate render_erb
|
activate render_erb
|
||||||
end
|
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
|
for_files(/\.html$/) do
|
||||||
activate apply_template("templates/lab.erb")
|
activate apply_template("templates/lab.erb")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## Specify specialized dependencies (e.g., on the database)
|
||||||
for_files(/people\/.*\.html$/) do
|
for_files(/people\/.*\.html$/) do
|
||||||
add_dependency "db/lab.json"
|
add_dependency "db/lab.json"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## Static assets
|
||||||
add_assets([
|
add_assets([
|
||||||
"bootstrap", "odin.css", "jquery.js", "logos"
|
"bootstrap", "odin.css", "jquery.js", "logos", "favicon", "people"
|
||||||
])
|
])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Before Width: | Height: | Size: 353 KiB After Width: | Height: | Size: 353 KiB |
|
@ -1,5 +1,6 @@
|
||||||
body {
|
body {
|
||||||
padding-top: 50px;
|
padding-top: 50px;
|
||||||
|
padding-bottom: 30px;
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
}
|
}
|
||||||
.starter-template {
|
.starter-template {
|
||||||
|
@ -15,7 +16,9 @@ body {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.person_list h1 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
.person_list .person {
|
.person_list .person {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
margin-bottom: 7px;
|
margin-bottom: 7px;
|
||||||
|
@ -39,3 +42,71 @@ body {
|
||||||
.person_list a {
|
.person_list a {
|
||||||
text-decoration: none;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
@ -56,7 +56,7 @@
|
||||||
"urls" : {
|
"urls" : {
|
||||||
"paper" : "http://odin.cse.buffalo.edu/papers/2016/ERMIS-final.pdf"
|
"paper" : "http://odin.cse.buffalo.edu/papers/2016/ERMIS-final.pdf"
|
||||||
},
|
},
|
||||||
"projects" : ["insiderthreats"]
|
"projects" : ["insider-threats"]
|
||||||
},
|
},
|
||||||
{ "title":"Pocket Data: The Need for TPC-MOBILE",
|
{ "title":"Pocket Data: The Need for TPC-MOBILE",
|
||||||
"authors":[
|
"authors":[
|
||||||
|
|
|
@ -20,23 +20,23 @@ module GemSmith
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_site(in_path, out_path, out_root)
|
def load_site(in_path, out_path)
|
||||||
if File.symlink? in_path then
|
if File.symlink? in_path then
|
||||||
$stderr.puts "Warning: Skipping symlink #{f}"
|
$stderr.puts "Warning: Skipping symlink #{f}"
|
||||||
[]
|
[]
|
||||||
elsif File.directory? in_path then
|
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}")]
|
directory "#{full_out_dir}" => [File.dirname("#{full_out_dir}")]
|
||||||
Dir["#{in_path}/*"].map do |f|
|
Dir["#{in_path}/*"].map do |f|
|
||||||
out_f = File.join(out_path, File.basename(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)
|
end.flatten(1)
|
||||||
else
|
else
|
||||||
[{
|
[{
|
||||||
modified: File.mtime(in_path),
|
modified: File.mtime(in_path),
|
||||||
in_path: in_path,
|
in_path: in_path,
|
||||||
dependencies: [in_path, File.dirname(File.join(out_root, out_path))],
|
dependencies: [in_path, File.dirname(File.join($gemsmith[:out_path], out_path))],
|
||||||
out_path: File.join(out_root, out_path),
|
out_path: out_path,
|
||||||
rel_dir: File.dirname(out_path),
|
rel_dir: File.dirname(out_path),
|
||||||
stream: Pipeline.new(in_path)
|
stream: Pipeline.new(in_path)
|
||||||
}]
|
}]
|
||||||
|
@ -46,7 +46,15 @@ module GemSmith
|
||||||
def for_files(pattern)
|
def for_files(pattern)
|
||||||
tmp = $gemsmith[:active]
|
tmp = $gemsmith[:active]
|
||||||
$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
|
yield
|
||||||
$gemsmith[:active] = tmp
|
$gemsmith[:active] = tmp
|
||||||
end
|
end
|
||||||
|
@ -60,7 +68,7 @@ module GemSmith
|
||||||
|
|
||||||
$gemsmith[:in_path] = in_path
|
$gemsmith[:in_path] = in_path
|
||||||
$gemsmith[:out_path] = out_path
|
$gemsmith[:out_path] = out_path
|
||||||
$gemsmith[:active] = load_site(in_path, "", out_path)
|
$gemsmith[:active] = load_site(in_path, "")
|
||||||
|
|
||||||
directory out_path
|
directory out_path
|
||||||
|
|
||||||
|
@ -69,9 +77,9 @@ module GemSmith
|
||||||
yield
|
yield
|
||||||
|
|
||||||
$gemsmith[:active].each { |f|
|
$gemsmith[:active].each { |f|
|
||||||
file f[:out_path] => f[:dependencies] do
|
file File.join(out_path, f[:out_path]) => f[:dependencies] do
|
||||||
error = nil;
|
error = nil;
|
||||||
File.open(f[:out_path], "w+") { |out|
|
File.open(File.join(out_path, f[:out_path]), "w+") { |out|
|
||||||
begin
|
begin
|
||||||
f[:stream].pipe_to(out)
|
f[:stream].pipe_to(out)
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -79,11 +87,11 @@ module GemSmith
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
unless error.nil?
|
unless error.nil?
|
||||||
File.unlink(f[:out_path])
|
File.unlink(File.join(out_path, f[:out_path]))
|
||||||
raise error
|
raise error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
task site_name => f[:out_path]
|
task site_name => File.join(out_path, f[:out_path])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -161,20 +169,41 @@ module GemSmith
|
||||||
in_dir = params.fetch(:source, "assets")
|
in_dir = params.fetch(:source, "assets")
|
||||||
out_dir = params.fetch(:dir, "assets")
|
out_dir = params.fetch(:dir, "assets")
|
||||||
assets.each { |a|
|
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)
|
$gemsmith[:assets][a] = File.join(out_dir, a)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def root_path
|
def add_file_string(out_path, data)
|
||||||
context = File.split($gemsmith[:now_rendering])
|
$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
|
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
|
end
|
||||||
|
|
||||||
def asset_path(asset)
|
def asset_path(asset)
|
||||||
target = $gemsmith[:assets][asset]
|
target = $gemsmith[:assets][asset]
|
||||||
return "???" if target.nil?
|
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
|
||||||
end
|
end
|
|
@ -7,10 +7,45 @@ module LabMetadata
|
||||||
|
|
||||||
members.each do |name, data|
|
members.each do |name, data|
|
||||||
data["link_relative"] = not(data.has_key? "link")
|
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"
|
unless data.has_key? "link"
|
||||||
data["link"] = "people/#{name.downcase.gsub(/ /, "_").gsub(/[^a-z0-9A-Z_]/, "")}.html"
|
data["link"] = page
|
||||||
end
|
end
|
||||||
|
data["page"] = page
|
||||||
end
|
end
|
||||||
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
|
end
|
|
@ -1,6 +1,20 @@
|
||||||
class Pipeline
|
class Pipeline
|
||||||
def initialize(file)
|
def initialize(source)
|
||||||
@op = lambda { |nxt| File.open(file) { |fp| nxt.call(fp) }}
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
def transform(&transformation)
|
def transform(&transformation)
|
||||||
|
|
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
Loading…
Reference in a new issue