Changeset 412


Ignore:
Timestamp:
Jun 28, 2016, 12:16:20 AM (3 years ago)
Author:
lars@…
Message:

Preparations to use the XML bundle in addition to the JSON to build the program.
There are hotcrp bugs in producing the bundle, so not in use yet.

Location:
www
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • www/Rules

    r401 r412  
    44ignore "/style.*"
    55
    6 # Don't upload the hotcrp json files
    7 ignore "/anrw/*/*.json"
     6# Don't upload the hotcrp json and xml files
     7ignore "/anrw/*/*.{xml,json}"
    88
    99compile "/**/*.haml" do
  • www/content/anrw/2016/program.haml

    r410 r412  
    4444
    4545- json = "content/anrw/2016/anrw16-data.json"
     46- xml = "content/anrw/2016/anrw16_jul16_16.xml"
    4647%table.table.table-striped.no-urlify
    4748  %thead
     
    6263      %td
    6364        %h4.text-danger Session: Multipath
     65
     66        -# .row= htmlify_paper(xml, 1)
     67        -# .row= htmlify_paper(xml, 2)
     68        -# .row= htmlify_paper(xml, 3)
     69        -# .row= htmlify_paper(xml, 4)
    6470
    6571        .row= htmlify_paper(json, 16)
  • www/lib/helper_anrw.rb

    r410 r412  
    22require "active_support/core_ext/string/inflections"
    33require "active_support/core_ext/array/conversions"
     4require 'active_support/core_ext/hash'
     5# require 'pp'
    46
    57module ANRW
    6   def htmlify_paper(json, nr)
    7     papers = JSON.parse(File.read(json))
    8     p = papers.select{ |p| p["pid"] == nr }[0]
    9     label =  p["options"]["type"] =~ /full/ ? "success" : "default"
     8  def htmlify_paper(file, nr)
     9    p = case File.extname(file)
     10    when ".json"
     11      JSON.parse(File.read(file)).select{ |x| x["pid"] == nr }[0]
     12    when ".xml"
     13      p = Hash.from_xml(File.read(file))["proceeding"]["content"]["section"].each{ |s|
     14        # pp nr, s["section_title"]
     15        a = s["article_rec"].find{ |x| x["seq_no"].to_i == nr }
     16        # pp nr, a["title"]
     17        return a
     18      }
     19      # pp nr, p
     20      {
     21        "options": { "type": (p["pages"].to_i > 4 ? "Full" : "Short") + " Paper" },
     22        "final": { "content_file": p["fulltext"]["file"]["fname"] },
     23        "authors": p["authors"]["au"].map { |a|
     24          {
     25            "first": a["first_name"],
     26            "last": a["last_name"],
     27            "affiliation": a["affiliation"]
     28          }
     29        },
     30        "title": p["title"],
     31        "abstract": p["abstract"].values.join(" ")
     32      }.deep_stringify_keys
     33    else
     34      raise "Don't know how to handle #{file}"
     35    end
     36    label = p["options"]["type"] =~ /full/i ? "success" : "default"
    1037    names = p["authors"].map { |a|
    1138      a["first"] + " " + a["last"] + (a.key?("affiliation") ?
    1239        " <em class=\"text-muted\">(" + a["affiliation"] + ")</em>" : "")
    1340    }
    14     pdf = File.join(File.dirname(json), p["final"]["content_file"])
     41    pdf = File.join(File.dirname(file), p["final"]["content_file"])
    1542
    1643    html = %{
     
    3057            </div>
    3158            <div class="modal-body">
    32               #{p["abstract"]}
     59              #{p["abstract"].gsub(/([[:alpha:]])-[[:space:]]+/, '\1')}
    3360            </div>
    3461            <div class="modal-footer">
Note: See TracChangeset for help on using the changeset viewer.