You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2018/01/25 15:08:17 UTC

[whimsy] branch master updated: Ensure app JS is reloaded when it changes

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 2fb4410  Ensure app JS is reloaded when it changes
2fb4410 is described below

commit 2fb44108d85df47f39718b107526b143d9f4c857
Author: Sebb <se...@apache.org>
AuthorDate: Thu Jan 25 15:08:15 2018 +0000

    Ensure app JS is reloaded when it changes
---
 www/roster/main.rb                  | 4 ++++
 www/roster/views/committee.html.rb  | 2 +-
 www/roster/views/committer.html.rb  | 2 +-
 www/roster/views/committers.html.rb | 2 +-
 www/roster/views/group.html.rb      | 2 +-
 www/roster/views/ppmc.html.rb       | 2 +-
 www/roster/views/ppmc_new.html.rb   | 2 +-
 7 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/www/roster/main.rb b/www/roster/main.rb
index 83c99cd..0ecac4d 100755
--- a/www/roster/main.rb
+++ b/www/roster/main.rb
@@ -31,6 +31,10 @@ helpers do
   def cssmtime
     File.mtime('public/stylesheets/app.css').to_i
   end
+  def appmtime
+    # TODO can this/should this be cached?
+    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
+  end
 end
 
 get '/' do
diff --git a/www/roster/views/committee.html.rb b/www/roster/views/committee.html.rb
index 968e8c1..7719e05 100644
--- a/www/roster/views/committee.html.rb
+++ b/www/roster/views/committee.html.rb
@@ -18,7 +18,7 @@ _html do
       _div_.main!
     end
 
-    _script src: 'app.js'
+    _script src: "app.js?#{appmtime}"
     _.render '#main' do
       _PMC committee: @committee, auth: @auth
     end
diff --git a/www/roster/views/committer.html.rb b/www/roster/views/committer.html.rb
index bf7c0cb..22dd36f 100644
--- a/www/roster/views/committer.html.rb
+++ b/www/roster/views/committer.html.rb
@@ -17,7 +17,7 @@ _html do
       _div_.main!
     end
 
-    _script src: 'app.js'
+    _script src: "app.js?#{appmtime}"
     _.render '#main' do
       _Person committer: @committer, auth: @auth
     end
diff --git a/www/roster/views/committers.html.rb b/www/roster/views/committers.html.rb
index 0e41713..75b4bbd 100644
--- a/www/roster/views/committers.html.rb
+++ b/www/roster/views/committers.html.rb
@@ -13,7 +13,7 @@ _html do
     }
   ) do
     _div_.main!
-    _script src: 'app.js'
+    _script src: "app.js?#{appmtime}"
     _.render '#main' do
       _CommitterSearch
     end
diff --git a/www/roster/views/group.html.rb b/www/roster/views/group.html.rb
index c8c3055..85555f1 100644
--- a/www/roster/views/group.html.rb
+++ b/www/roster/views/group.html.rb
@@ -18,7 +18,7 @@ _html do
       _div_.main!
     end
 
-    _script src: 'app.js'
+    _script src: "app.js?#{appmtime}"
     _.render '#main' do
       _Group group: @group, auth: @auth
     end
diff --git a/www/roster/views/ppmc.html.rb b/www/roster/views/ppmc.html.rb
index df3fe32..5cae494 100644
--- a/www/roster/views/ppmc.html.rb
+++ b/www/roster/views/ppmc.html.rb
@@ -16,7 +16,7 @@ _html do
       }
     ) do
       _div_.main!
-      _script src: 'app.js'
+      _script src: "app.js?#{appmtime}"
       _.render '#main' do
         _PPMC ppmc: @ppmc, auth: @auth
       end
diff --git a/www/roster/views/ppmc_new.html.rb b/www/roster/views/ppmc_new.html.rb
index 992e592..e7050f3 100644
--- a/www/roster/views/ppmc_new.html.rb
+++ b/www/roster/views/ppmc_new.html.rb
@@ -18,7 +18,7 @@ _html do
       _div_.main!
     end
 
-    _script src: 'app.js'
+    _script src: "app.js?#{appmtime}"
     _.render '#main' do
       _PPMCNew auth: @auth, pmcsAndBoard: @pmcsAndBoard,
         officersAndMemers: @officersAndMembers, ipmc: @ipmc

-- 
To stop receiving notification emails like this one, please contact
sebb@apache.org.

Re: [whimsy] branch master updated: Ensure app JS is reloaded when it changes

Posted by Sam Ruby <ru...@intertwingly.net>.
On Thu, Jan 25, 2018 at 11:50 AM, sebb <se...@gmail.com> wrote:
> On 25 January 2018 at 16:37, Sam Ruby <ru...@intertwingly.net> wrote:
>> On Thu, Jan 25, 2018 at 11:32 AM, sebb <se...@gmail.com> wrote:
>>> On 25 January 2018 at 16:20, Sam Ruby <ru...@intertwingly.net> wrote:
>>>> On Thu, Jan 25, 2018 at 10:08 AM,  <se...@apache.org> wrote:
>>>>> +  def appmtime
>>>>> +    # TODO can this/should this be cached?
>>>>> +    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
>>>>
>>>> Wunderbar::Asset.convert caches the results.  It checks the timestamps
>>>> of each of the files that are pulled together to produce the desired
>>>> output.
>>>
>>> Yes.
>>>
>>> I meant could/should the result of the check be cached?
>>> As is done with csstime.
>>
>> I'm confused:
>>
>>   def cssmtime
>>     File.mtime('public/stylesheets/app.css').to_i
>>   end
>>   def appmtime
>>     # TODO can this/should this be cached?
>>     Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
>>   end
>>
>> Where is cssmtime cached?
>
> Sorry, I was referring to the @cssmtime field used elsewhere in the
> code (not in roster)

I'm not aware of any code that caches @cssmtime.  Some code computes
cssmtime in specific routes and passes it as an instance variable to
the view.  Other code defines a helper that is called by the view.

> Since File.mtime is likely to be very quick, there did not seem to be
> a need to cache the result here

Agreed.

> But convert is more expensive.

But convert caches the result to avoid this expense :-)

Specifically, look here:

https://github.com/rubys/wunderbar/blob/master/lib/wunderbar/render.rb#L13

In particular, the following line:

return cached if cached and cached.uptodate?

This, in turn makes use of:

https://github.com/rubys/ruby2js/blob/master/lib/ruby2js/serializer.rb#L66

- Sam Ruby

Re: [whimsy] branch master updated: Ensure app JS is reloaded when it changes

Posted by sebb <se...@gmail.com>.
On 25 January 2018 at 16:37, Sam Ruby <ru...@intertwingly.net> wrote:
> On Thu, Jan 25, 2018 at 11:32 AM, sebb <se...@gmail.com> wrote:
>> On 25 January 2018 at 16:20, Sam Ruby <ru...@intertwingly.net> wrote:
>>> On Thu, Jan 25, 2018 at 10:08 AM,  <se...@apache.org> wrote:
>>>> +  def appmtime
>>>> +    # TODO can this/should this be cached?
>>>> +    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
>>>
>>> Wunderbar::Asset.convert caches the results.  It checks the timestamps
>>> of each of the files that are pulled together to produce the desired
>>> output.
>>
>> Yes.
>>
>> I meant could/should the result of the check be cached?
>> As is done with csstime.
>
> I'm confused:
>
>   def cssmtime
>     File.mtime('public/stylesheets/app.css').to_i
>   end
>   def appmtime
>     # TODO can this/should this be cached?
>     Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
>   end
>
> Where is cssmtime cached?

Sorry, I was referring to the @cssmtime field used elsewhere in the
code (not in roster)

Since File.mtime is likely to be very quick, there did not seem to be
a need to cache the result here

But convert is more expensive.

> - Sam Ruby

Re: [whimsy] branch master updated: Ensure app JS is reloaded when it changes

Posted by Sam Ruby <ru...@intertwingly.net>.
On Thu, Jan 25, 2018 at 11:32 AM, sebb <se...@gmail.com> wrote:
> On 25 January 2018 at 16:20, Sam Ruby <ru...@intertwingly.net> wrote:
>> On Thu, Jan 25, 2018 at 10:08 AM,  <se...@apache.org> wrote:
>>> +  def appmtime
>>> +    # TODO can this/should this be cached?
>>> +    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
>>
>> Wunderbar::Asset.convert caches the results.  It checks the timestamps
>> of each of the files that are pulled together to produce the desired
>> output.
>
> Yes.
>
> I meant could/should the result of the check be cached?
> As is done with csstime.

I'm confused:

  def cssmtime
    File.mtime('public/stylesheets/app.css').to_i
  end
  def appmtime
    # TODO can this/should this be cached?
    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
  end

Where is cssmtime cached?

- Sam Ruby

Re: [whimsy] branch master updated: Ensure app JS is reloaded when it changes

Posted by sebb <se...@gmail.com>.
On 25 January 2018 at 16:20, Sam Ruby <ru...@intertwingly.net> wrote:
> On Thu, Jan 25, 2018 at 10:08 AM,  <se...@apache.org> wrote:
>> +  def appmtime
>> +    # TODO can this/should this be cached?
>> +    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i
>
> Wunderbar::Asset.convert caches the results.  It checks the timestamps
> of each of the files that are pulled together to produce the desired
> output.

Yes.

I meant could/should the result of the check be cached?
As is done with csstime.

> - Sam Ruby

Re: [whimsy] branch master updated: Ensure app JS is reloaded when it changes

Posted by Sam Ruby <ru...@intertwingly.net>.
On Thu, Jan 25, 2018 at 10:08 AM,  <se...@apache.org> wrote:
> +  def appmtime
> +    # TODO can this/should this be cached?
> +    Wunderbar::Asset.convert("#{settings.views}/app.js.rb").mtime.to_i

Wunderbar::Asset.convert caches the results.  It checks the timestamps
of each of the files that are pulled together to produce the desired
output.

- Sam Ruby