Why
MicroReader is written in PowerShell. If you are not interested in PowerShell or you are not willing to learn it, you can stop reading right now.
My first microblogging service was Jaiku. My friend nikdo brought me there. It was a great time there until they started cutting features and Jaiku was more down then working. So we decided to move to Twitter. It is completely other world. One of features that I missed very much were replies that are bound to the root "question". It's much more difficult to follow the original idea than on Jaiku. This was the first reason why I started working on a reader that is capable to display replies as expected.
Features
Grouping replies
As mentioned in the intro, replies are grouped together to its original question. Visually you can display them with a left margin. If there is a new status that is bound to a parent and you have read the parent already (so it is not returned in new statuses list), the parent status is downloaded as well so that the reader knows the original question. The extra-downloaded status is shown in 0.33 opacity (see the second image on the left).
More accounts support
After I started on Twitter I added many people to my "following" list. E.g. Scott Hanselman was one of them. You know that Scott tweets quite often, and it was hard to follow him because his tweets include personal things as well that I'm not interested in. Therefore I created new account at Twitter only for reading tweets from some people only when I have time for that.
That's why I needed multiaccount support. Besided that the reader supports Identi.ca as well, because Identi.ca offers the same API as Twitter.
Removing tweets from some people
It's possible from any reason to remove some people. For example I follow halr9000 on Twitter and Identi.ca. He posts the same to both services. So currently I simply remove his posts to Identi.ca.
Tweets backup
After tweets are downloaded, they are stored to disk for possible later processing. E.g. you might want to make a statistics or just store them for better search based on your needs.
How to use it
First, I assume that you know what PowerShell is and you have PowerShell on your machine installed.
Second, if you want to use the MicroReader fully (to display tweets, not just for downloading), you need to download PowerBoots provided by Jaykul. It's a great PowerShell module to bring WPF into PowerShell world. There are of course some other ways, but PowerBoots simplify working with WPF quite noticeably.
MicroReader is a PowerShell module as well. So the functionality is wrapped inside and some objects can not be used. If you would like to see the internals from console as well, just rename it to *.ps1 and remove the last line with Export-ModuleMember.
Note: I refer to tweets as statuses (general term not bound only to Twitter)
Initialization
Download the zip file and unpack it into its own directory. In further examples let's assume you unpacked it into directory d:\MicroReader.
We import the module and PowerBoots (I assume you have installed PowerBoots already).
[1] Import-Module d:\MicroReader\check-microblogs.psm1
[2] Import-Module powerboots
We create a new session. The first parameter is root directory where some files are stored:
- images identifying Twitter and Identi.ca
- last fetched status id for each service
- directory 'statuses' for the downloaded statuses
- directory 'images' for cached avatars of statuses authors
- last xml response from servers with prefix currStatuses and directMessages
The second directory is optional and it will be needed when you will backup statuses (pack them into a zip archive). It should be directory with 7zip packer. Then we add your credentials. The color there is just for function that displays the statuses, it helps to distinguish the service the status is bound to.
[3] New-MbSession D:\MicroReader\ G:\Programs\7zip\ # we initialize the session
[4] Add-MbTwitter stejcz password Green
[5] Add-MbTwitter leporeloeu password # uses default color - white
[6] Add-MbIdentica stej password Red
Getting new statuses
Now we can try to get some statuses. When we use MicroReader for the first time, up to 100 statuses per account will be downloaded. Command Start-MbPreview opens new PowerBoots window in its own thread (thx Jaykul).
[7] Start-MbPreview
You can see the result on the left. Downloaded statuses are stored in global variable $mbStatuses. The reader checks for new statuses every 10 minutes. If you want to display them, just click on Finish – after that replies will be bound to their reply parents (i.e. original questions), so some more statuses will be probably downloaded. To display the statuses just try the following command. Warning: the more statuses to display the more slow are PowerBoots. If you will try it for the first one, be really patient.
[8] $global:mbStatuses | Show-MbStatuses
After you are done, you can just open new preview window again: [9] Start-MbPreview. You can specify -treshold parameter. If there are less statuses downloaded than the treshold, the window's opacity is 0.4. Parameter -delay denotes amount of minutes between attempts to download new statuses.
The Exit button on the preview window only closes the window, it means that reply parents are not downloaded and no status is marked as hidden.
Backup services
When time is up and you have to switch your computer off, you might want to backup your services, so that you don't have to add them via Add-MbTwitter/Identica next time.
[10] Export-MbServices
To be more secure you have to provide a password.
If you have the services stored on disk, it makes sense to import them (next time you switch on the computer). To import them just try:
[11] Import-MbServices
Internal functions
There is a function called Check-Microblog. It simply downloads all the new statuses, removes the unwated ones and adds reply parents. It is defined like this:
function Check-Microblog {
param(
[Parameter(Position=0, Mandatory=$false)][object[]]$itemsToRemove
)
($global:mbStatuses = Get-MbStatuses |
Remove-MbStatuses |
Add-MbReplyParents
) | Show-MbStatuses
}
From the code above you can see some helpful functions:
Get-MbStatuses- Is used for downloading of new statuses. It internally loads files with last statuses id for each service and checks the
appropriate url with credentials you passed to
Add-MbTwitter. You can pass as in statuses already returned by Get-MbStatuses (only new statuses are added) or pass in $null.
Remove-MbStatuses- Marks some statuses as hidden. It depends on the displaying function how it handles hidden statuses. Currently
Show-MbStatuses shows them in grey color.
Add-MbReplyParents- This function adds the reply parent for each status whose
ReplyId refers to other status.
Removing statuses
As I said earlier it is possible to remove (just download and optionally not display) some statuses. To setup the default filter that is used by Show-MbPreview use this command:
[12] Set-MbDefaultRemoveFilters @{'Account'='Identica'; 'User'='halr9000'}
[13] Get-MbDefaultRemoveFilters
Name Value
---- -----
Account Identica
User halr9000
If you don't specify any default filter, you can pass it in later to the Remove-MbStatuses function explicitly. For more examples check the module source and look for Remove-MbStatuses.
Simplify startup
I grouped some commands together, put them into a function and included into my profile file:
function Start-MbSession { param([switch]$powerBoots)
Import-Module d:\MicroReader\check-microblogs.psm1
Import-MBSession d:\MicroReader c:\prgs\7zip
if ($powerBoots) {
Import-Module powerboots
}
Set-MBDefaultRemoveFilters @(@{'App'='Identica';'User'='halr9000'}, 'webdesigndev', `
'fczbkk', 'emilylewis', 'NETTUTS')
}
Some TODOs
There are still some possible features to add, that wait only in my mind.
- Now it's needed to close the window opened from
Start-MbPreview and after that to open new
window from command line (by Show-MbStatuses). It would be much better to add a button to the preview window that would open the statuses for reading. Currently I had some problems caused probably by inproper use of PowerBoots.
- Possibility to pass a script block to
Remove-MbStatuses. Then I could hide all RT statuses easily.
- The functionality can be ported to .NET and used on web site or in exe file, so it's not needed to have PowerShell installed on the computer.
- Make WPF layout prettier. It's priority is not high, but why not ;) I think that I need to review the controls used to make loading of the window with statuses faster.
- Use background thread for downloading statuses, because the preview windows is frozen when downloading new statuses. However, priority of this TODO is quite low.
- Remove scrollbars when not needd.
- Remove "Drag me" button and enable drag & drop on the whole window.
The psm1 file is quite big, it grew very much since the first versions. I'm C# programmer, so it's possible that some constructions could be done more elegantly in PowerShell. In this case don't hesitate and contact me.
Download and contact
In case you have something to tell me, contact me on Twitter, Identi.ca, mail me at stej{-at-}leporelo{#dot#}eu or fill a Contact form.
In the zip file there is a powershell module and twitter and identica images that are used for statuses background.