Merge branch 'master' into assistant
This commit is contained in:
commit
de792c35e4
9 changed files with 178 additions and 7 deletions
|
@ -26,6 +26,10 @@ References:
|
|||
* <http://stackoverflow.com/questions/5151858/running-a-haskell-program-on-the-android-os>
|
||||
* <http://www.reddit.com/r/haskell/comments/ful84/haskell_on_android/>
|
||||
|
||||
I've heard anecdoally that ipwnstudios not only has an IPhone GHC port,
|
||||
but also Android. Need to get in touch with them.
|
||||
<http://ipwnstudios.com/>
|
||||
|
||||
### Android specific features
|
||||
|
||||
The app should be aware of power status, and avoid expensive background
|
||||
|
|
68
doc/design/assistant/blog/day_46__notification_pools.mdwn
Normal file
68
doc/design/assistant/blog/day_46__notification_pools.mdwn
Normal file
|
@ -0,0 +1,68 @@
|
|||
Focus today was writing a notification broadcaster library. This is a way to
|
||||
send a notification to a set of clients, any of which can be blocked
|
||||
waiting for a new notification to arrive. A complication is that any number
|
||||
of clients may be be dead, and we don't want stale notifications for those
|
||||
clients to pile up and leak memory.
|
||||
|
||||
It took me 3 tries to find the solution, which turns out to be head-smackingly
|
||||
simple: An array of SampleVars, one per client.
|
||||
|
||||
Using SampleVars means that clients only see the most recent notification,
|
||||
but when the notification is just "the assistant's state changed somehow;
|
||||
display a refreshed rendering of it", that's sufficient.
|
||||
|
||||
----
|
||||
|
||||
First use of that was to make the thread that woke up every 10 minutes
|
||||
and checkpointed the daemon status to disk also wait for a notification
|
||||
that it changed. So that'll be more current, and use less IO.
|
||||
|
||||
----
|
||||
|
||||
Second use, of course, was to make the WebApp block long polling clients
|
||||
until there is really a change since the last time the client polled.
|
||||
|
||||
To do that, I made one change to my Yesod routes:
|
||||
|
||||
[[!format diff """
|
||||
-/status StatusR GET
|
||||
+/status/#NotificationId StatusR GET
|
||||
"""]]
|
||||
|
||||
Now I find another reason to love Yesod, because after doing that,
|
||||
I hit "make".. and fixed the type error. And hit make.. and fixed
|
||||
the type error. And then it just freaking worked! Html was generated with
|
||||
all urls to /status including a `NotificationId`, and the handler for
|
||||
that route got it and was able to use it:
|
||||
|
||||
[[!format haskell """
|
||||
{- Block until there is an updated status to display. -}
|
||||
b <- liftIO $ getNotificationBroadcaster webapp
|
||||
liftIO $ waitNotification $ notificationHandleFromId b nid
|
||||
"""]]
|
||||
|
||||
And now the WebApp is able to display transfers in realtime!
|
||||
When I have both the WebApp and `git annex get` running on the same screen,
|
||||
the WebApp displays files that git-annex is transferring about as fast
|
||||
as the terminal updates.
|
||||
|
||||
The [[progressbars]] still need to be sorted out, but otherwise
|
||||
the WebApp is a nice live view of file transfers.
|
||||
|
||||
---
|
||||
|
||||
I also had some fun with Software Transactional Memory. Now when the
|
||||
assistant moves a transfer from its queue of transfers to do, to its map of
|
||||
transfers that are currently running, it does so in an atomic transaction.
|
||||
This will avoid the transfer seeming to go missing (or be listed twice) if
|
||||
the webapp refreshes at just the wrong point in time. I'm really starting
|
||||
to get into STM.
|
||||
|
||||
----
|
||||
|
||||
Next up, I will be making the WebApp maintain a list of notices, displayed
|
||||
on its sidebar, scrolling new notices into view, and removing ones the user
|
||||
closes, and ones that expire. This will be used for displaying errors, as
|
||||
well as other communication with the user (such as displaying a notice
|
||||
while a git sync is in progress with a remote, etc). Seems worth doing now,
|
||||
so the basic UI of the WebApp is complete with no placeholders.
|
14
doc/design/assistant/blog/day_47__alert_messages.mdwn
Normal file
14
doc/design/assistant/blog/day_47__alert_messages.mdwn
Normal file
|
@ -0,0 +1,14 @@
|
|||
Some days I spend 2 hours chasing red herrings (like "perhaps my JSON ajax
|
||||
calls arn't running asynchronoously?") that turn out to be a simple
|
||||
one-word typo. This was one of them.
|
||||
|
||||
However, I did get the sidebar displaying alert messages, which can be
|
||||
easily sent to the user from any part of the assistant. This includes
|
||||
transient alerts of things it's doing, which disappear once the action
|
||||
finishes, and long-term alerts that are displayed until the user closes
|
||||
them. It even supports rendering arbitrary Yesod widgets as alerts, so
|
||||
they can also be used for asking questions, etc.
|
||||
|
||||
Time for a screencast!
|
||||
|
||||
<video controls src="http://joeyh.name/screencasts/git-annex-webapp.ogg"></video>
|
|
@ -0,0 +1,18 @@
|
|||
[[!comment format=mdwn
|
||||
username="https://www.google.com/accounts/o8/id?id=AItOawkpEY8WTFDhjIVTWG38Ph7ppmuXUTJAHAg"
|
||||
nickname="Justin"
|
||||
subject="selective sync"
|
||||
date="2012-07-28T04:08:00Z"
|
||||
content="""
|
||||
hey joey
|
||||
|
||||
great work!!
|
||||
|
||||
will partial content work like selective sync in dropbox
|
||||
|
||||
use case: on desktop i have photos/mp3s/docs, but would only want to sync the docs to my netbook
|
||||
|
||||
cheers
|
||||
|
||||
justin
|
||||
"""]]
|
|
@ -16,7 +16,7 @@ The webapp is a web server that displays a shiny interface.
|
|||
|
||||
## interface
|
||||
|
||||
* list of files uploading and downloading
|
||||
* list of files uploading and downloading **done**
|
||||
* progress bars for each file
|
||||
* drag and drop to reorder
|
||||
* cancel and pause
|
||||
|
@ -27,15 +27,14 @@ The webapp is a web server that displays a shiny interface.
|
|||
* there could be a UI to export a file, which would make it be served up
|
||||
over http by the web app
|
||||
* Display any relevant warning messages. One is the `inotify max_user_watches`
|
||||
exceeded message. Need to lift such messages into DaemonStatus
|
||||
so the WebApp can include them in its rendering of DaemonStatus.
|
||||
exceeded message.
|
||||
|
||||
## implementation
|
||||
|
||||
* perhaps define a custom `errorHandler`, which could avoid the potential
|
||||
of leaking auth tokens on error pages. Or make the test suite test for
|
||||
leakage.
|
||||
* possibly lose the ugly auth= token past the first page,
|
||||
and use a client-side session. It could be encrypted using the token
|
||||
as the `encryptKey`. Note: Would need to set the session duration
|
||||
to infinite (how?)
|
||||
* Fix notification handle leakage on pages other than the main page.
|
||||
The javascript should use AJAX to request handles, that way
|
||||
they won't be allocated at all in noscript.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue