{"id":78,"date":"2009-07-04T14:07:42","date_gmt":"2009-07-04T21:07:42","guid":{"rendered":"http:\/\/kai.mactane.org\/blog\/?p=78"},"modified":"2009-07-04T14:07:42","modified_gmt":"2009-07-04T21:07:42","slug":"notes-on-lj-content-sieve","status":"publish","type":"post","link":"https:\/\/kagan.mactane.org\/blog\/2009\/07\/04\/notes-on-lj-content-sieve\/","title":{"rendered":"Notes on LJ Content Sieve"},"content":{"rendered":"<p>My latest project is something I call &#8220;LJ Content Sieve&#8221;: a Greasemonkey script to filter out content on one&#8217;s Livejournal views based on nearly any attribute of a post or comment.<\/p>\n<p>However, Livejournal is very customizable. It has 31 different &#8220;layouts&#8221;, each of which can then be further &#8220;themed&#8221; by application of CSS. This means that a user viewing a given journal, community, or single post, at a given time, may receive an HTML document containing any of 31 different DOM structures.<\/p>\n<p>This means that finding a post&#8217;s author, or title, or even just a single post or comment, is not a straightforward process. I&#8217;ve set myself up a Ruby script that downloaded my &#8220;friends&#8221; view, a representative entry with lots of comments, and my own journal view, thus giving me a set of 93 fixtures that I can test against. The Ruby script also tweaked each fixture in the process of spooling it to my hard drive, by adding the proper calls to JSUnit files.<\/p>\n<p>At the end of each document&#8217;s &lt;head&gt; element, there&#8217;s a call to <code>jsUnitCore.js<\/code>. Then, at the end of each &lt;body&gt;, I add a call to the <code>lj-content-sieve.user.js<\/code> script itself, as well as a set of test files that depends on which fixture this is. Every fixture gets an <code>ljcs-global-tests.js<\/code> call added to it&nbsp;&mdash; that file contains tests that should work anywhere, regardless of what sort of page you&#8217;re on.<\/p>\n<p>Then all the &#8220;friends&#8221; page fixtures get an <code>ljcs-friends-tests.js<\/code> file, which tests operations that should happen on every friends page. For example, determining which entries need to be deleted. (In contrast, single-entry pages get <code>ljcs-entry-tests.js<\/code>, and the page from my own journal&nbsp;&mdash; which stands in for a view of a community&nbsp;&mdash; gets <code>ljcs-self-tests.js<\/code>.)<\/p>\n<p>Finally, each fixture page gets a test file based on its layout: the &#8220;3 Column&#8221; layout gets <code>ljcs-3&nbsp;Column-tests.js<\/code>, while &#8220;Cuteness Attack&#8221; gets <code>ljcs-Cuteness&nbsp;Attack-tests.js<\/code>. (Hey, I didn&#8217;t write or name the layouts; I just have to make sure LJCS works with all of &#8217;em.) These files will test that the actual DOM manipulations work properly.<\/p>\n<p>Without test-driven development and automated testing to ensure that each layout and page-type is being handled properly, I don&#8217;t think this project would be manageable at all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My latest project is something I call &#8220;LJ Content Sieve&#8221;: a Greasemonkey script to filter out content on one&#8217;s Livejournal views based on nearly any attribute of a post or comment. However, Livejournal is very customizable. It has 31 different &#8220;layouts&#8221;, each of which can then be further &#8220;themed&#8221; by application of CSS. This means [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[37,7,38,6],"_links":{"self":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/78"}],"collection":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":1,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/78\/revisions\/79"}],"wp:attachment":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}