From a9ac1c4bb8c28bd15d767006082098715122430b Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Fri, 17 Feb 2017 10:31:24 -0800 Subject: [PATCH 1/2] adjusted parser to handle < and > to address issue #18 and even added a little love <3 --- assets/.assets.index | 4 ++-- assets/ProfilePage.qml | 3 ++- assets/parser.js | 5 +++-- translations/Goober.ts | 26 +++++++++++++------------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/assets/.assets.index b/assets/.assets.index index b5fa242..564fe2e 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,12 +1,10 @@ 1 47 -AboutPage.qml AppCover.qml LoginSheet.qml main.qml moment.js NewPostSheet.qml -PostItem.qml ProfilePage.qml RefreshItem.qml SettingsPage.qml @@ -44,6 +42,8 @@ icons/retweet.png icons/sign-out.png icons/star-o.png icons/star.png +PostItem.qml StreamTab.qml WebViewSheet.qml parser.js +AboutPage.qml diff --git a/assets/ProfilePage.qml b/assets/ProfilePage.qml index 55466d2..0f831c0 100644 --- a/assets/ProfilePage.qml +++ b/assets/ProfilePage.qml @@ -19,6 +19,7 @@ import bb.cascades 1.4 import org.labsquare 1.0 +import "parser.js" as Parser Page { @@ -109,7 +110,7 @@ Page { preferredWidth: ui.du(45) Label { //text: lorem - text: user.content.html + text: Parser.parsePostData(user.content.html) multiline: true textFormat: TextFormat.Html } diff --git a/assets/parser.js b/assets/parser.js index a4e8c07..2b5202f 100644 --- a/assets/parser.js +++ b/assets/parser.js @@ -236,8 +236,9 @@ function parsePostData(t) { t = t.replace(/þ/g,"\u00FE"); t = t.replace(/ÿ/g,"\u00FF"); t = t.replace(/"/g,"\u0022"); - t = t.replace(/</g,"\u003C"); - t = t.replace(/>/g,"\u003E"); + t = t.replace(/<3/g, "\u2764"); + t = t.replace(/</g,"\u02C2"); + t = t.replace(/>/g,"\u02C3"); t = t.replace(/€/g,"\u0080"); t = t.replace(/‚/g,"\u0082"); t = t.replace(/ƒ/g,"\u0083"); diff --git a/translations/Goober.ts b/translations/Goober.ts index 1e1cfda..4e6cc43 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -78,55 +78,55 @@ ProfilePage - - + + Following - - + + Followers - - + + Posts - + Bookmarks - + Unfollow - + Follow - + Unmute - + Mute - + Unblock - + Block From a4a50b6b5ac36c2a8eccf139afa2ed46bf80cef2 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Fri, 17 Feb 2017 12:53:16 -0800 Subject: [PATCH 2/2] render oembed photos, issue #12 --- assets/PostItem.qml | 17 ++++++++++++++++- src/Pnut.cpp | 2 ++ translations/Goober.ts | 18 +++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/assets/PostItem.qml b/assets/PostItem.qml index bde8abd..0bde87e 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -29,7 +29,6 @@ Container { rightPadding: ui.sdu(3.0) topPadding: ui.sdu(2.0) //bottomPadding: ui.sdu(2.0) - property string lorem: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non enim tellus. Donec vestibulum enim urna, eget faucibus diam commodo a. Donec eget hendrerit metus. Pellentesque vehicula nisi nec vehicula ullamcorper. Aliquam a elit eget mi fringilla porta fermentum eget eros. Phasellus vestibulum nulla sed elit congue adipiscing. Cras imperdiet urna ac ipsum volutpat lobortis. Maecenas vehicula tortor at viverra convallis. Curabitur nibh massa, tristique id felis ut, venenatis faucibus dui. Donec fringilla, mi nec tincidunt dignissim, neque nunc semper mi, quis rutrum diam turpis sit amet erat. Cras a sodales nisi. Nunc sit amet diam sed lectus molestie cursus convallis et erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis vitae varius leo. Mauris eu leo a nunc bibendum rutrum euismod et ipsum. " property variant theme : Application.themeSupport.theme.colorTheme.style @@ -144,6 +143,22 @@ Container { navigation.focusPolicy: NavigationFocusPolicy.NotFocusable } } + Container { + horizontalAlignment: HorizontalAlignment.Center + bottomMargin: ui.sdu(2.0) + WebImageView { + url: { + var oembed = "" + ListItemData.raw.forEach(function (item) { + if (item["type"] == "io.pnut.core.oembed") { + oembed = item["value"]["url"] + } + }) + return oembed + } + scalingMethod: ScalingMethod.AspectFit + } + } Container { layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 9737c48..b92f6d2 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -335,6 +335,7 @@ void Pnut::getStream(QString endpoint, Pnut::RequestType rtype) QUrl url(PNUT_API_ROOT + endpoint); KQOAuthParameters parameters; parameters.insert("count", "50"); + parameters.insert("include_raw", "1"); switch (rtype) { case Pnut::STREAM_NEWER: @@ -400,6 +401,7 @@ void Pnut::getThread(QString pid) { QUrl url(PNUT_API_ROOT + "/posts/" + pid + "/thread"); KQOAuthParameters parameters; + parameters.insert("include_raw", "1"); req_map[++req_id] = ":thread"; getRequest(url, parameters, req_id); } diff --git a/translations/Goober.ts b/translations/Goober.ts index 4e6cc43..e0f4432 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -30,47 +30,47 @@ PostItem - + Reply - + Reply All - + Add Bookmark - + Delete Bookmark - + Repost - + Delete Repost - + Quote - + View Profile - + Delete