From 1e026a772f96cbe14ecd16fa27ab911877a59701 Mon Sep 17 00:00:00 2001 From: Tofe Date: Tue, 3 Apr 2012 07:56:22 +0200 Subject: [PATCH] Fix and first attempt to use Readability 1. Fix on modification of a Source 2. Beginnning of integration of Readability in a WebView --- .../content/css/readability-print.css | 88 ++++++++++++++++++++ qml/QuickNewsReader/content/css/readability.css | 87 +++++++++++++++++++ qml/QuickNewsReader/content/view/NewsComments.qml | 3 + .../content/view/SourceDelegate.qml | 1 + 4 files changed, 179 insertions(+) create mode 100755 qml/QuickNewsReader/content/css/readability-print.css create mode 100755 qml/QuickNewsReader/content/css/readability.css create mode 100644 qml/QuickNewsReader/content/js/Readability.js diff --git a/qml/QuickNewsReader/content/css/readability-print.css b/qml/QuickNewsReader/content/css/readability-print.css new file mode 100755 index 0000000..83e2e81 --- /dev/null +++ b/qml/QuickNewsReader/content/css/readability-print.css @@ -0,0 +1,88 @@ +body, #readOverlay { + background-color: white !important; +} + +embed, object { + display: none !important; +} + +/*#readInner { + width: 100% !important; +} +*/ +#readInner.margin-x-narrow {width:100% !important;} +#readInner.margin-narrow {width:91% !important;} +#readInner.margin-medium {width:84% !important;} +#readInner.margin-wide {width:77% !important;} +#readInner.margin-x-wide {width:70% !important;} + +#readTools { + display: none !important; +} + +#readFooter { + font-size: .85em; + text-align: left !important; +} + +#readFooter a { + border-bottom-width: 0 !important; +} + +#readability-url { + display: inline !important; +} + +#rdb-footer-print { + display: block !important; + font-size: .85em; + text-align: right; + margin-bottom: 1.5em; +} + +#rdb-footer-print span { + white-space: ; +} + +#rdb-footer-left { + width: auto !important; + display: block !important; + float: none !important; + font-family: "Adobe Caslon Pro", "Hoefler Text", Georgia, Garamond, serif; +} + +#rdb-footer-right { + display: none !important; +} + +#readFooter #arc90-logo, #readFooter #readability-logo { + background-image: none !important; + text-indent: 0 !important; + width: auto !important; + height: auto !important; + line-height: auto !important; + margin: 0 !important; + text-align: left; +} + +#readFooter #readability-logo { + color: #333 !important; + font-variant: small-caps; +} + +#footer-twitterLink { + display: none; +} + +#readFooter span.version { + display: none; +} + +a { + color: #333 !important; + border-bottom: 1px solid #CCC !important; +} + +div.footer-right { + display: none; +} diff --git a/qml/QuickNewsReader/content/css/readability.css b/qml/QuickNewsReader/content/css/readability.css new file mode 100755 index 0000000..50cdfa8 --- /dev/null +++ b/qml/QuickNewsReader/content/css/readability.css @@ -0,0 +1,87 @@ +@charset "utf-8"; +/* Document */ +body{font-size:10px;line-height:1;} +#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;} +#readOverlay{text-rendering:optimizeLegibility;display:block;position:absolute;top:0;left:0;width:100%;} +#readInner{max-width:800px;margin:1em auto;} +#readInner a{color:#039;text-decoration:none;} +#readInner a:hover,#readInner a:focus{text-decoration:underline;} +#readInner img{float:left;clear:both;margin:0 12px 12px 0;} +#readInner img.blockImage{clear:both;float:none;display:block;margin-left:auto;margin-right:auto;} +#readInner h1{display:block;width:100%;border-bottom:1px solid #333;font-size:1.2em;padding-bottom:.5em;margin-bottom:.75em;} +#readInner sup{line-height:.8em;} +#readInner .page-separator{clear:both;display:block;font-size:.85em;filter:alpha(opacity=20);opacity:.20;text-align:center;} +.style-apertura #readInner h1{border-bottom-color:#ededed;} +.style-terminal #readInner h1{border-bottom-color:#c6ffc6;} +#readInner blockquote{margin-left:3em;margin-right:3em;} +#readability-inner *{margin-bottom:16px;border:none;background:none;} +#readability-footnotes{clear:both;} +/* Footer */ +#rdb-footer-wrapper{display:block;border-top:1px solid #333;clear:both;overflow:hidden;margin:2em 0;} +.style-apertura #rdb-footer-wrapper{border-top-color:#ededed;} +.style-terminal #rdb-footer-wrapper{border-top-color:#c6ffc6;} +#rdb-footer-left{display:inline;float:left;margin-top:15px;width:285px;background-position:0 -36px;} +.rdbTypekit #rdb-footer-left{width:475px;} +#rdb-footer-left a,#rdb-footer-left a:link{float:left;} +#readability-logo{display:inline;background-position:0 -36px;height:29px;width:189px;text-indent:-9000px;} +#arc90-logo{display:inline;background-position:right -36px;height:29px;width:96px;text-indent:-9000px;} +.style-apertura #readability-logo,.style-terminal #readability-logo{background-position:0 -67px;} +.style-apertura #arc90-logo,.style-terminal #arc90-logo{background-position:right -67px;} +#rdb-footer-right{display:inline;float:right;text-align:right;font-size:.75em;margin-top:18px;} +#rdb-footer-right a{display:inline-block;float:left;overflow:visible;line-height:16px;vertical-align:baseline;} +.footer-twitterLink{height:20px;margin-left:20px;background-position:0 -123px;font-size:12px;padding:4px 0 0 28px;} +#rdb-footer-left .footer-twitterLink{display:none;margin-top:1px;padding-top:2px;} +.rdbTypekit #rdb-footer-left .footer-twitterLink{display:inline-block!important;} +a.rdbTK-powered,a.rdbTK-powered:link,a.rdbTK-powered:hover{font-size:16px;color:#858789!important;text-decoration:none!important;} +a.rdbTK-powered span{display:inline-block;height:22px;margin-left:2px;background-position:0 -146px!important;padding:4px 0 0 26px;} +.style-apertura #rdb-inverse,.style-athelas #rdb-athelas{display:block;} +#rdb-footer-print,#readability-url,.rdbTypekit #rdb-footer-right .footer-twitterLink,span.version{display:none;} +/* Tools */ +#readTools{width:34px;height:150px;position:fixed;z-index:100;top:10px;left:10px;} +#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);} +#reload-page{background-position:0 0;} +#print-page{background-position:-36px 0;} +#email-page{background-position:-72px 0;} +#kindle-page{background-position:-108px 0;} +#readTools a:hover,#readTools a:focus{opacity:1;filter:alpha(opacity=100);} +/* @group User Styles */ +/* Size */ +.size-x-small{font-size:1.1em;line-height:1.5em;} +.size-small{font-size:1.4em;line-height:1.5em;} +.size-medium{font-size:1.7em;line-height:1.48em;} +.size-large{font-size:2em;line-height:1.47em;} +.size-x-large{font-size:2.5em;line-height:1.43em;} +.size-x-small h1,.size-small h1,.size-medium h1,.size-large h1{font-size:1.6em;line-height:1.5em;} +.size-x-large h1{font-size:1.6em;line-height:1.3em;} +/* Style */ +.style-newspaper {font-family:Georgia,"Times New Roman", Times, serif;background:#fbfbfb;color:#080000;} +.style-newspaper h1 {text-transform:capitalize;font-family:Georgia, "Times New Roman", Times, serif;} +.style-newspaper #readInner a {color:#0924e1;} +.style-novel {font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;background:#f4eed9;color:#1d1916;} +.style-novel #readInner a {color:#1856ba;} +.style-ebook {font-family:Arial, Helvetica, sans-serif;background:#edebe8;color:#2c2d32;} +.style-ebook #readInner a {color:#187dc9;} +.style-ebook h1 {font-family:"Arial Black", Gadget, sans-serif;font-weight:400;} +.style-terminal {font-family:"Lucida Console", Monaco, monospace;background:#1d4e2c;color:#c6ffc6;} +.style-terminal #readInner a {color:#093;} +/* Typekit */ +.style-apertura{font-family:apertura-1,apertura-2,sans-serif;background-color:#2d2828;color:#eae8e9;} +.style-apertura #readInner a{color:#58b0ff;} +.style-athelas{font-family:athelas-1,athelas-2,"Palatino Linotype","Book Antiqua",Palatino,serif;background-color:#f7f7f7;color:#2b373d;} +.style-athelas #readInner a{color:#1e83cb;} +/* Margin */ +.margin-x-narrow{width:95%;} +.margin-narrow{width:85%;} +.margin-medium{width:75%;} +.margin-wide{width:55%;} +.margin-x-wide{width:35%;} +/* @end User Styles */ +/* -- DEBUG -- */ +.bug-green{background:#bbf9b0;border:4px solid green;} +.bug-red{background:red;} +.bug-yellow{background:#ffff8e;} +.bug-blue{background:#bfdfff;} +/* -- EMAIL / KINDLE POP UP -- */ +#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;} +/* Override html styling attributes */ +table,tr,td{background-color:transparent!important;} diff --git a/qml/QuickNewsReader/content/js/Readability.js b/qml/QuickNewsReader/content/js/Readability.js new file mode 100644 index 0000000..e69de29 diff --git a/qml/QuickNewsReader/content/view/NewsComments.qml b/qml/QuickNewsReader/content/view/NewsComments.qml index b31887d..ae825f8 100644 --- a/qml/QuickNewsReader/content/view/NewsComments.qml +++ b/qml/QuickNewsReader/content/view/NewsComments.qml @@ -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); } } } diff --git a/qml/QuickNewsReader/content/view/SourceDelegate.qml b/qml/QuickNewsReader/content/view/SourceDelegate.qml index 1fb2372..8e3495d 100644 --- a/qml/QuickNewsReader/content/view/SourceDelegate.qml +++ b/qml/QuickNewsReader/content/view/SourceDelegate.qml @@ -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 }) -- 1.7.9.5