Fix and first attempt to use Readability
authorTofe <chris.chapuis+gitorious@gmail.com>
Tue, 3 Apr 2012 05:56:22 +0000 (07:56 +0200)
committerTofe <chris.chapuis+gitorious@gmail.com>
Tue, 3 Apr 2012 05:56:22 +0000 (07:56 +0200)
1. Fix on modification of a Source
2. Beginnning of integration of Readability in a WebView

qml/QuickNewsReader/content/css/readability-print.css [new file with mode: 0755]
qml/QuickNewsReader/content/css/readability.css [new file with mode: 0755]
qml/QuickNewsReader/content/js/Readability.js [new file with mode: 0644]
qml/QuickNewsReader/content/view/NewsComments.qml
qml/QuickNewsReader/content/view/SourceDelegate.qml

diff --git a/qml/QuickNewsReader/content/css/readability-print.css b/qml/QuickNewsReader/content/css/readability-print.css
new file mode 100755 (executable)
index 0000000..83e2e81
--- /dev/null
@@ -0,0 +1,88 @@
+body, #readOverlay {\r
+       background-color: white !important;\r
+}\r
+\r
+embed, object {\r
+       display: none !important;\r
+}\r
+\r
+/*#readInner {\r
+    width: 100% !important;\r
+}\r
+*/\r
+#readInner.margin-x-narrow {width:100% !important;}\r
+#readInner.margin-narrow {width:91% !important;}\r
+#readInner.margin-medium {width:84% !important;}\r
+#readInner.margin-wide {width:77% !important;}\r
+#readInner.margin-x-wide {width:70% !important;}\r
+\r
+#readTools {\r
+       display: none !important;\r
+}\r
+\r
+#readFooter {\r
+       font-size: .85em;\r
+       text-align: left !important;\r
+}\r
+\r
+#readFooter a {\r
+    border-bottom-width: 0 !important;\r
+}\r
+\r
+#readability-url {\r
+       display: inline !important;\r
+}\r
+\r
+#rdb-footer-print {\r
+    display: block !important;\r
+    font-size: .85em;\r
+    text-align: right;\r
+    margin-bottom: 1.5em;\r
+}\r
+\r
+#rdb-footer-print span {\r
+    white-space: ;\r
+}\r
+\r
+#rdb-footer-left {\r
+    width: auto !important;\r
+    display: block !important;\r
+    float: none !important;\r
+    font-family: "Adobe Caslon Pro", "Hoefler Text", Georgia, Garamond, serif;\r
+}\r
+\r
+#rdb-footer-right {\r
+    display: none !important;\r
+}\r
+\r
+#readFooter #arc90-logo, #readFooter #readability-logo {\r
+    background-image: none !important;\r
+    text-indent: 0 !important;\r
+    width: auto !important;\r
+    height: auto !important;\r
+    line-height: auto !important;\r
+    margin: 0 !important;\r
+       text-align: left;\r
+}\r
+\r
+#readFooter #readability-logo {\r
+       color: #333 !important;\r
+       font-variant: small-caps;\r
+}\r
+\r
+#footer-twitterLink {\r
+    display: none;\r
+}\r
+\r
+#readFooter span.version {\r
+       display: none;\r
+}\r
+\r
+a {\r
+       color: #333 !important;\r
+       border-bottom: 1px solid #CCC !important;\r
+}\r
+\r
+div.footer-right {\r
+       display: none;\r
+}\r
diff --git a/qml/QuickNewsReader/content/css/readability.css b/qml/QuickNewsReader/content/css/readability.css
new file mode 100755 (executable)
index 0000000..50cdfa8
--- /dev/null
@@ -0,0 +1,87 @@
+@charset "utf-8";\r
+/* Document */\r
+body{font-size:10px;line-height:1;}\r
+#readability-logo,#arc90-logo,.footer-twitterLink,#readTools a,a.rdbTK-powered span{background-color:transparent!important;background-image:url(http://lab.arc90.com/experiments/readability/images/sprite-readability.png)!important;background-repeat:no-repeat!important;}\r
+#readOverlay{text-rendering:optimizeLegibility;display:block;position:absolute;top:0;left:0;width:100%;}\r
+#readInner{max-width:800px;margin:1em auto;}\r
+#readInner a{color:#039;text-decoration:none;}\r
+#readInner a:hover,#readInner a:focus{text-decoration:underline;}\r
+#readInner img{float:left;clear:both;margin:0 12px 12px 0;}\r
+#readInner img.blockImage{clear:both;float:none;display:block;margin-left:auto;margin-right:auto;}\r
+#readInner h1{display:block;width:100%;border-bottom:1px solid #333;font-size:1.2em;padding-bottom:.5em;margin-bottom:.75em;}\r
+#readInner sup{line-height:.8em;}\r
+#readInner .page-separator{clear:both;display:block;font-size:.85em;filter:alpha(opacity=20);opacity:.20;text-align:center;}\r
+.style-apertura #readInner h1{border-bottom-color:#ededed;}\r
+.style-terminal #readInner h1{border-bottom-color:#c6ffc6;}\r
+#readInner blockquote{margin-left:3em;margin-right:3em;}\r
+#readability-inner *{margin-bottom:16px;border:none;background:none;}\r
+#readability-footnotes{clear:both;}\r
+/* Footer */\r
+#rdb-footer-wrapper{display:block;border-top:1px solid #333;clear:both;overflow:hidden;margin:2em 0;}\r
+.style-apertura #rdb-footer-wrapper{border-top-color:#ededed;}\r
+.style-terminal #rdb-footer-wrapper{border-top-color:#c6ffc6;}\r
+#rdb-footer-left{display:inline;float:left;margin-top:15px;width:285px;background-position:0 -36px;}\r
+.rdbTypekit #rdb-footer-left{width:475px;}\r
+#rdb-footer-left a,#rdb-footer-left a:link{float:left;}\r
+#readability-logo{display:inline;background-position:0 -36px;height:29px;width:189px;text-indent:-9000px;}\r
+#arc90-logo{display:inline;background-position:right -36px;height:29px;width:96px;text-indent:-9000px;}\r
+.style-apertura #readability-logo,.style-terminal #readability-logo{background-position:0 -67px;}\r
+.style-apertura #arc90-logo,.style-terminal #arc90-logo{background-position:right -67px;}\r
+#rdb-footer-right{display:inline;float:right;text-align:right;font-size:.75em;margin-top:18px;}\r
+#rdb-footer-right a{display:inline-block;float:left;overflow:visible;line-height:16px;vertical-align:baseline;}\r
+.footer-twitterLink{height:20px;margin-left:20px;background-position:0 -123px;font-size:12px;padding:4px 0 0 28px;}\r
+#rdb-footer-left .footer-twitterLink{display:none;margin-top:1px;padding-top:2px;}\r
+.rdbTypekit #rdb-footer-left .footer-twitterLink{display:inline-block!important;}\r
+a.rdbTK-powered,a.rdbTK-powered:link,a.rdbTK-powered:hover{font-size:16px;color:#858789!important;text-decoration:none!important;}\r
+a.rdbTK-powered span{display:inline-block;height:22px;margin-left:2px;background-position:0 -146px!important;padding:4px 0 0 26px;}\r
+.style-apertura #rdb-inverse,.style-athelas #rdb-athelas{display:block;}\r
+#rdb-footer-print,#readability-url,.rdbTypekit #rdb-footer-right .footer-twitterLink,span.version{display:none;}\r
+/* Tools */\r
+#readTools{width:34px;height:150px;position:fixed;z-index:100;top:10px;left:10px;}\r
+#readTools a{overflow:hidden;margin-bottom:8px;display:block;opacity:.4;text-indent:-99999px;height:34px;width:34px;text-decoration:none;filter:alpha(opacity=40);}\r
+#reload-page{background-position:0 0;}\r
+#print-page{background-position:-36px 0;}\r
+#email-page{background-position:-72px 0;}\r
+#kindle-page{background-position:-108px 0;}\r
+#readTools a:hover,#readTools a:focus{opacity:1;filter:alpha(opacity=100);}\r
+/* @group User Styles */\r
+/* Size */\r
+.size-x-small{font-size:1.1em;line-height:1.5em;}\r
+.size-small{font-size:1.4em;line-height:1.5em;}\r
+.size-medium{font-size:1.7em;line-height:1.48em;}\r
+.size-large{font-size:2em;line-height:1.47em;}\r
+.size-x-large{font-size:2.5em;line-height:1.43em;}\r
+.size-x-small h1,.size-small h1,.size-medium h1,.size-large h1{font-size:1.6em;line-height:1.5em;}\r
+.size-x-large h1{font-size:1.6em;line-height:1.3em;}\r
+/* Style */\r
+.style-newspaper {font-family:Georgia,"Times New Roman", Times, serif;background:#fbfbfb;color:#080000;}\r
+.style-newspaper h1 {text-transform:capitalize;font-family:Georgia, "Times New Roman", Times, serif;}\r
+.style-newspaper #readInner a {color:#0924e1;}\r
+.style-novel {font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;background:#f4eed9;color:#1d1916;}\r
+.style-novel #readInner a {color:#1856ba;}\r
+.style-ebook {font-family:Arial, Helvetica, sans-serif;background:#edebe8;color:#2c2d32;}\r
+.style-ebook #readInner a {color:#187dc9;}\r
+.style-ebook h1 {font-family:"Arial Black", Gadget, sans-serif;font-weight:400;}\r
+.style-terminal {font-family:"Lucida Console", Monaco, monospace;background:#1d4e2c;color:#c6ffc6;}\r
+.style-terminal #readInner a {color:#093;}\r
+/* Typekit */\r
+.style-apertura{font-family:apertura-1,apertura-2,sans-serif;background-color:#2d2828;color:#eae8e9;}\r
+.style-apertura #readInner a{color:#58b0ff;}\r
+.style-athelas{font-family:athelas-1,athelas-2,"Palatino Linotype","Book Antiqua",Palatino,serif;background-color:#f7f7f7;color:#2b373d;}\r
+.style-athelas #readInner a{color:#1e83cb;}\r
+/* Margin */\r
+.margin-x-narrow{width:95%;}\r
+.margin-narrow{width:85%;}\r
+.margin-medium{width:75%;}\r
+.margin-wide{width:55%;}\r
+.margin-x-wide{width:35%;}\r
+/* @end User Styles */\r
+/* -- DEBUG -- */\r
+.bug-green{background:#bbf9b0;border:4px solid green;}\r
+.bug-red{background:red;}\r
+.bug-yellow{background:#ffff8e;}\r
+.bug-blue{background:#bfdfff;}\r
+/* -- EMAIL / KINDLE POP UP -- */\r
+#kindle-container,#email-container{position:fixed;top:60px;left:50%;width:500px;height:490px;border:solid 3px #666;background-color:#fff;z-index:100!important;overflow:hidden;margin:0 0 0 -240px;padding:0;}\r
+/* Override html styling attributes */\r
+table,tr,td{background-color:transparent!important;}\r
diff --git a/qml/QuickNewsReader/content/js/Readability.js b/qml/QuickNewsReader/content/js/Readability.js
new file mode 100644 (file)
index 0000000..e69de29
index b31887d..ae825f8 100644 (file)
@@ -70,7 +70,10 @@ Item {
                 // on the maemo platform, the background is dark gray by default, so change it to white
                 onLoadFinished: {
                     newsCommentsWebView.evaluateJavaScript("document.bgColor = '#FFFFFF';")
+                    //newsCommentsWebView.evaluateJavaScript("readConvertLinksToFootnotes=false;readStyle='style-newspaper';readSize='size-medium';readMargin='margin-wide';_readability_script=document.createElement('script');_readability_script.type='text/javascript';_readability_script.src='file:///home/chris/dev/arc90labs-readability/js/readability.js?x='+(Math.random());document.documentElement.appendChild(_readability_script);_readability_css=document.createElement('link');_readability_css.rel='stylesheet';_readability_css.href='file:///home/chris/dev/arc90labs-readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.documentElement.appendChild(_readability_css);_readability_print_css=document.createElement('link');_readability_print_css.rel='stylesheet';_readability_print_css.href='file:///home/chris/dev/arc90labs-readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css);readability.init();")
                 }
+
+                onAlert: console.log(message);
             }
         }
     }
index 1fb2372..8e3495d 100644 (file)
@@ -69,6 +69,7 @@ Item {
                 delegate.ListView.view.currentIndex = index
 
                 listSourceModel[index].currentPath = [index]
+                currentSourceIndex = index
 
                 window.windowViewsModel.append({ component: listSourceModel[index].listViews[0].viewComponent,
                                                  componentDepth: 1 })