From commits-return-334-apmail-whimsical-commits-archive=whimsical.apache.org@whimsical.apache.org Fri Jan 22 02:41:03 2016 Return-Path: X-Original-To: apmail-whimsical-commits-archive@minotaur.apache.org Delivered-To: apmail-whimsical-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17DBF18C86 for ; Fri, 22 Jan 2016 02:41:00 +0000 (UTC) Received: (qmail 98263 invoked by uid 500); 22 Jan 2016 02:41:00 -0000 Delivered-To: apmail-whimsical-commits-archive@whimsical.apache.org Received: (qmail 98242 invoked by uid 500); 22 Jan 2016 02:41:00 -0000 Mailing-List: contact commits-help@whimsical.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@whimsical.apache.org Delivered-To: mailing list commits@whimsical.apache.org Received: (qmail 98233 invoked by uid 99); 22 Jan 2016 02:40:59 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jan 2016 02:40:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 8DB9B180583 for ; Fri, 22 Jan 2016 02:40:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.247 X-Spam-Level: * X-Spam-Status: No, score=1.247 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 4GXeXs6UPtbD for ; Fri, 22 Jan 2016 02:40:55 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 6937C31B11 for ; Fri, 22 Jan 2016 02:40:54 +0000 (UTC) Received: from matt.apache.org (unknown [207.244.88.130]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 5EA16E0FD8 for ; Fri, 22 Jan 2016 02:40:53 +0000 (UTC) Received: by matt.apache.org (ASF Mail Server at matt.apache.org, from userid 33) id 1AC16803B; Fri, 22 Jan 2016 02:40:52 +0000 (UTC) From: Sam Ruby Reply-To: commits@whimsical.apache.org To: commits@whimsical.apache.org Subject: [whimsy.git] [4/50] Commit 3fa92b2: brute force an item page Message-Id: <20160122024052.1AC16803B@matt.apache.org> Date: Fri, 22 Jan 2016 02:40:52 +0000 (UTC) Commit 3fa92b2aef17a1a5a70f89525c3ba5f801b73537: brute force an item page Branch: refs/heads/master Author: Sam Ruby Committer: Sam Ruby Pusher: rubys ------------------------------------------------------------ main.rb | + spec/item_spec.rb | ++++++++++++++ views/agenda.js.rb | +++++++++ - views/main.html.rb | + - views/main.js.rb | +++++++ --- ------------------------------------------------------------ 75 changes: 61 additions, 14 deletions. ------------------------------------------------------------ diff --git a/main.rb b/main.rb index b133516..2597c32 100755 --- a/main.rb +++ b/main.rb @@ -31,6 +31,7 @@ Dir.chdir(FOUNDATION_BOARD) {@agendas = Dir['board_agenda_*.txt'].sort} Dir.chdir(FOUNDATION_BOARD) {@drafts = Dir['board_minutes_*.txt'].sort} @base = env['PATH_INFO'].chomp(path).untaint + @path = path @agenda = "board_agenda_#{date.gsub('-','_')}.txt" if AGENDA_CACHE[@agenda][:mtime] == 0 diff --git a/spec/item_spec.rb b/spec/item_spec.rb new file mode 100644 index 0000000..be7a89b --- /dev/null +++ b/spec/item_spec.rb @@ -0,0 +1,14 @@ +require_relative 'spec_helper' + +feature 'item' do + it "should show the Secretary report" do + visit '/2014-02-19/Secretary' + expect(page).to have_selector '.navbar-fixed-top .navbar-brand', + text: 'Secretary' + expect(page).to have_selector 'pre', text: /December doldrums/ + expect(page).to have_selector '.backlink[href="Treasurer"]', + text: 'Treasurer' + expect(page).to have_selector '.nextlink[href="Executive-Vice-President"]', + text: 'Executive Vice President' + end +end diff --git a/views/agenda.js.rb b/views/agenda.js.rb index e1df46a..bcbbbc5 100644 --- a/views/agenda.js.rb +++ b/views/agenda.js.rb @@ -3,12 +3,25 @@ class Agenda def self.load(list) @@index.clear() + prev = nil list.each do |item| - @@index << Agenda.new(item) + item = Agenda.new(item) + item.prev = prev + prev.next = item if prev + prev = item + @@index << item end return @@index end + def self.find(path) + result = nil + @@index.each do |item| + result = item if item.href == path + end + return result + end + def initialize(entry) for name in entry self["_#{name}"] = entry[name] @@ -21,6 +34,10 @@ def href @title.gsub(/[^a-zA-Z0-9]+/, '-') end + def text + @text || @report + end + def color if not @title 'blank' diff --git a/views/main.html.rb b/views/main.html.rb index 78f7b5d..21fec60 100755 --- a/views/main.html.rb +++ b/views/main.html.rb @@ -13,6 +13,6 @@ _script src: '../app.js' _.render '#main' do - _Main parsed: @parsed, agenda: @agenda, agendas: @agendas + _Main parsed: @parsed, agenda: @agenda, agendas: @agendas, path: @path end end diff --git a/views/main.js.rb b/views/main.js.rb index 7a94785..862c77b 100644 --- a/views/main.js.rb +++ b/views/main.js.rb @@ -1,26 +1,36 @@ class Main < React def initialize @agenda = Agenda.load(@@parsed) - @date = @@agenda[/(\d+_\d+_\d+)/, 1].gsub('_', '-') @next = {text: 'Help', link: 'help'} @prev = {text: 'Help', link: 'help'} - @@agendas.each do |agenda| - date = agenda[/(\d+_\d+_\d+)/, 1].gsub('_', '-') + if @@path + @item = Agenda.find(@@path) + @prev = {text: @item.prev.title, link: @item.prev.href} if @item.prev + @next = {text: @item.next.title, link: @item.next.href} if @item.next + @color = @item.color + @title = @item.title + else + @date = @@agenda[/(\d+_\d+_\d+)/, 1].gsub('_', '-') + @title = @date + @color = 'blank' + @@agendas.each do |agenda| + date = agenda[/(\d+_\d+_\d+)/, 1].gsub('_', '-') - if date > @date and (@next.text == 'Help' or date < @next.text) - @next = {text: date, link: "../#{date}/"} - end + if date > @date and (@next.text == 'Help' or date < @next.text) + @next = {text: date, link: "../#{date}/"} + end - if date < @date and (@prev.text == 'Help' or date > @prev.text) - @prev = {text: date, link: "../#{date}/"} + if date < @date and (@prev.text == 'Help' or date > @prev.text) + @prev = {text: date, link: "../#{date}/"} + end end end end def render - _header.navbar.navbar_fixed_top.blank do - _div.navbar_brand @date + _header.navbar.navbar_fixed_top class: @color do + _div.navbar_brand @title _ul.nav.nav_pills.navbar_right do _li.dropdown do _a.dropdown_toggle.nav! 'navigation' @@ -29,10 +39,14 @@ def render end _main do - React.createElement(Index, agenda: @agenda) + if @item + _pre @item.text + else + React.createElement(Index, agenda: @agenda) + end end - _footer.navbar.navbar_fixed_bottom.blank do + _footer.navbar.navbar_fixed_bottom class: @color do _a.backlink.navbar_brand @prev.text, rel: 'prev', href: @prev.link _a.nextlink.navbar_brand @next.text, rel: 'next', href: @next.link end @@ -47,6 +61,7 @@ def window.onresize() main.style.marginBottom = "#{footer.clientHeight}px" end + document.getElementsByTagName('title')[0].textContent = @title window.onresize() end