summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/postrunner/ActivitiesDB.rb38
-rw-r--r--lib/postrunner/Activity.rb17
-rw-r--r--lib/postrunner/ActivityReport.rb2
-rw-r--r--lib/postrunner/ActivityView.rb8
-rw-r--r--lib/postrunner/ViewWidgets.rb6
5 files changed, 59 insertions, 12 deletions
diff --git a/lib/postrunner/ActivitiesDB.rb b/lib/postrunner/ActivitiesDB.rb
index 6dd3593..0e21e65 100644
--- a/lib/postrunner/ActivitiesDB.rb
+++ b/lib/postrunner/ActivitiesDB.rb
@@ -93,6 +93,16 @@ module PostRunner
activity.register_records(@records)
+ # The HTML activity views contain links to their predecessors and
+ # successors. After inserting a new activity, we need to re-generate
+ # these views as well.
+ if (pred = predecessor(activity))
+ pred.generate_html_view
+ end
+ if (succ = successor(activity))
+ succ.generate_html_view
+ end
+
sync
Log.info "#{fit_file} successfully added to archive"
@@ -100,7 +110,17 @@ module PostRunner
end
def delete(activity)
+ pred = predecessor(activities)
+ succ = successor(activities)
+
@activities.delete(activity)
+
+ # The HTML activity views contain links to their predecessors and
+ # successors. After deleting an activity, we need to re-generate these
+ # views as well.
+ pred.generate_html_view if pred
+ succ.generate_html_view if succ
+
sync
end
@@ -155,6 +175,22 @@ module PostRunner
[]
end
+ # Return the next Activity after the provided activity. Note that this has
+ # a lower index. If none is found, return nil.
+ def successor(activity)
+ idx = @activities.index(activity)
+ return nil if idx.nil? || idx == 0
+ @activities[idx - 1]
+ end
+
+ # Return the previous Activity before the provided activity. Note that
+ # this has a higher index. If none is found, return nil.
+ def predecessor(activity)
+ idx = @activities.index(activity)
+ return nil if idx.nil? || idx >= @activities.length - 2
+ @activities[idx + 1]
+ end
+
def map_to_files(query)
case query
when /\A-?\d+$\z/
@@ -189,7 +225,7 @@ module PostRunner
# Show the activity list in a web browser.
def show_list_in_browser
- #ActivityListView.new(self).update_html_index
+ ActivityListView.new(self).update_html_index
show_in_browser(File.join(@html_dir, 'index.html'))
end
diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb
index 8a0b2a2..70ab1ca 100644
--- a/lib/postrunner/Activity.rb
+++ b/lib/postrunner/Activity.rb
@@ -38,7 +38,7 @@ module PostRunner
self.class.send(:attr_reader, v.to_sym)
end
# Generate HTML file for this activity.
- ActivityView.new(self)
+ generate_html_view
end
def late_init(db)
@@ -48,10 +48,9 @@ module PostRunner
end
def check
- @fit_activity = load_fit_file
- Log.info "FIT file #{@fit_file} is OK"
# Re-generate the HTML file for this activity
- ActivityView.new(self)
+ generate_html_view
+ Log.info "FIT file #{@fit_file} is OK"
end
def dump(filter)
@@ -82,9 +81,7 @@ module PostRunner
end
def show
- @fit_activity = load_fit_file unless @fit_activity
-
- ActivityView.new(self) #unless File.exists?(@html_file)
+ generate_html_view #unless File.exists?(@html_file)
@db.show_in_browser(@html_file)
end
@@ -96,6 +93,7 @@ module PostRunner
def rename(name)
@name = name
+ generate_html_view
end
def register_records(db)
@@ -110,6 +108,11 @@ module PostRunner
end
end
+ def generate_html_view
+ @fit_activity = load_fit_file unless @fit_activity
+ ActivityView.new(self, @db.predecessor(self), @db.successor(self))
+ end
+
private
def load_fit_file(filter = nil)
diff --git a/lib/postrunner/ActivityReport.rb b/lib/postrunner/ActivityReport.rb
index 65edc48..f15ed91 100644
--- a/lib/postrunner/ActivityReport.rb
+++ b/lib/postrunner/ActivityReport.rb
@@ -35,7 +35,7 @@ module PostRunner
def to_html(doc)
session = @activity.fit_activity.sessions[0]
- frame(doc, "Summary of #{@activity.name}") {
+ frame(doc, "Activity: #{@activity.name}") {
summary(session).to_html(doc)
}
frame(doc, 'Laps') {
diff --git a/lib/postrunner/ActivityView.rb b/lib/postrunner/ActivityView.rb
index 6c487c2..7cfe3fb 100644
--- a/lib/postrunner/ActivityView.rb
+++ b/lib/postrunner/ActivityView.rb
@@ -24,8 +24,10 @@ module PostRunner
include ViewWidgets
- def initialize(activity)
+ def initialize(activity, predecessor, successor)
@activity = activity
+ @predecessor = predecessor
+ @successor = successor
@output_dir = activity.html_dir
@output_file = nil
@@ -87,7 +89,9 @@ EOT
def body(doc)
doc.body({ :onload => 'init()' }) {
- titlebar(doc)
+ prev_page = @predecessor ? @predecessor.fit_file[0..-5] + '.html' : nil
+ next_page = @successor ? @successor.fit_file[0..-5] + '.html' : nil
+ titlebar(doc, nil, prev_page, 'index.html', next_page)
# The main area with the 2 column layout.
doc.div({ :class => 'main' }) {
doc.div({ :class => 'left_col' }) {
diff --git a/lib/postrunner/ViewWidgets.rb b/lib/postrunner/ViewWidgets.rb
index 6533418..b4b4207 100644
--- a/lib/postrunner/ViewWidgets.rb
+++ b/lib/postrunner/ViewWidgets.rb
@@ -28,6 +28,10 @@ module PostRunner
font-style: italic;
font-weight: bold;
color: #F8F8F8;
+ text-shadow: -1px -1px 0 #5C5C5C,
+ 1px -1px 0 #5C5C5C,
+ -1px 1px 0 #5C5C5C,
+ 1px 1px 0 #5C5C5C;
padding: 3px 30px;
}
.navigator {
@@ -66,7 +70,7 @@ module PostRunner
}
.flexitable {
width: 100%;
- border: 1px solid #CCCCCC;
+ border: 2px solid #545454;
border-collapse: collapse;
font-size:11pt;
}