restructured files into directories

This commit is contained in:
Jeena 2015-02-27 08:52:34 +01:00
parent b05b6e34a3
commit b6c0d89f1f
25 changed files with 33 additions and 304 deletions

View file

@ -0,0 +1,65 @@
html, body {
margin: 0;
padding: 0;
}
body {
background: #eee;
font-family: sans-serif;
padding: 10pt 15pt;
font-weight: lighter;
}
h1 {
font-weight: lighter;
font-size: 1.4em;
margin: 0;
padding: 0;
}
#date:not(:empty) {
border-bottom: 1px solid #aaa;
margin-bottom: 1em;
padding-bottom: 1em;
display: block;
}
.starred:after {
content: "*";
}
header p {
color: #aaa;
margin: 0;
padding: 0;
font-size: 0.8em;
}
a {
color: inherit;
text-decoration: none;
}
article {
line-height: 1.6;
}
article a {
text-decoration: underline;
}
blockquote {
font-style: italic;
}
img {
max-width: 100%;
height: auto;
}
div > a:only-child img, figure > a:only-child img, p > a:only-child img,
figure > img:only-child, div > img:only-child, p > img:only-child {
display: block;
margin: 1em auto;
float: none !important;
}

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TTRSS</title>
<link href="content.css" media="all" rel="stylesheet">
<script type="text/javascript" src="content.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
</head>
<body class=''>
<header>
<p><span id="feed_title"></span> <span id="author"></span></p>
<h1><a id="title" href=""></a></h1>
<p><timedate id="date"></timedate></p>
</header>
<article id="article"></article>
</body>
</html>

49
resources/html/content.js Normal file
View file

@ -0,0 +1,49 @@
function $(id) {
return document.getElementById(id);
}
function setArticle(article) {
window.scrollTo(0, 0);
$("date").innerHTML = "";
$("title").innerHTML = "";
$("title").href = "";
$("title").title = "";
$("feed_title").innerHTML = "";
$("author").innerHTML = "";
$("article").innerHTML = "";
if(article === "empty") {
$("article").innerHTML = "No unread articles to display.";
} else if(article === "loading") {
$("article").innerHTML = "Loading <blink>&hellip;</blink>";
} else if (article === "logout") {
} else if(article) {
$("date").innerHTML = (new Date(parseInt(article.updated, 10) * 1000));
$("title").innerHTML = article.title;
$("title").href = article.link;
$("title").title = article.link;
$("feed_title").innerHTML = article.feed_title;
$("title").className = article.marked ? "starred" : "";
$("author").innerHTML = "";
if(article.author && article.author.length > 0)
$("author").innerHTML = "&ndash; " + article.author
$("article").innerHTML = article.content;
var as = $("article").getElementsByTagName("a");
for(var i = 0; i <= as.length; i++) {
as[i].target = "";
}
}
}
function setFont(font, size) {
document.body.style.fontFamily = font;
document.body.style.fontSize = size + "pt";
}

BIN
resources/misc/Icon.icns Normal file

Binary file not shown.

View file

@ -0,0 +1,12 @@
[Desktop Entry]
Version=2.0.0
Comment=A desktop client for the TinyTinyRSS feed reader.
Exec=feedthemonkey
GenericName=Feed Reader
Icon=feedthemonkey
Name=FeedTheMonkey
NoDisplay=false
StartupNotify=true
Terminal=false
Type=Application
Categories=Network;Qt

File diff suppressed because it is too large Load diff

91
resources/qml/Content.qml Normal file
View file

@ -0,0 +1,91 @@
import QtWebKit 3.0
import QtWebKit.experimental 1.0
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.3
import QtQuick.Controls 1.3
import TTRSS 1.0
ScrollView {
id: content
property Post post
property ApplicationWindow app
property int textFontSize: 14
property int scrollJump: 48
property int pageJump: parent.height
Layout.minimumWidth: 400
onTextFontSizeChanged: webView.setDefaults()
style: ScrollViewStyle {
transientScrollBars: true
}
function scrollDown(jump) {
if(!jump) {
webView.experimental.evaluateJavaScript("window.scrollTo(0, document.body.scrollHeight - " + height + ");")
} else {
webView.experimental.evaluateJavaScript("window.scrollBy(0, " + jump + ");")
}
}
function scrollUp(jump) {
if(!jump) {
webView.experimental.evaluateJavaScript("window.scrollTo(0, 0);")
} else {
webView.experimental.evaluateJavaScript("window.scrollBy(0, -" + jump + ");")
}
}
function loggedOut() {
post = null
}
Label { id: fontLabel }
WebView {
id: webView
url: "content.html"
// Enable communication between QML and WebKit
experimental.preferences.navigatorQtObjectEnabled: true;
property Post post: content.post
function setPost() {
if(post) {
experimental.evaluateJavaScript("setArticle(" + post.jsonString + ")")
} else {
experimental.evaluateJavaScript("setArticle('logout')")
}
}
function setDefaults() {
// font name needs to be enclosed in single quotes
experimental.evaluateJavaScript("document.body.style.fontFamily = \"'" + fontLabel.font.family + "'\";");
experimental.evaluateJavaScript("document.body.style.fontSize = '" + content.textFontSize + "pt';");
}
onNavigationRequested: {
if (request.navigationType != WebView.LinkClickedNavigation) {
request.action = WebView.AcceptRequest;
} else {
request.action = WebView.IgnoreRequest;
Qt.openUrlExternally(request.url);
}
}
onLoadingChanged: {
if(loadRequest.status === WebView.LoadSucceededStatus) {
setPost()
setDefaults()
}
}
onPostChanged: setPost()
Keys.onPressed: app.keyPressed(event)
}
}

65
resources/qml/Login.qml Normal file
View file

@ -0,0 +1,65 @@
import QtQuick 2.0
import QtQuick.Controls 1.2
Rectangle {
color: "transparent"
anchors.fill: parent
property string serverUrl: serverUrl.text
property string userName: userName.text
property string password: password.text
Column {
anchors.centerIn: parent
width: parent.width / 2
anchors.margins: parent.width / 4
spacing: 10
Text {
text: qsTr("Please specify a server url, a username and a password.")
wrapMode: Text.WordWrap
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 20
font.pointSize: 20
}
TextField {
id: serverUrl
placeholderText: "http://example.com/ttrss/"
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 20
validator: RegExpValidator { regExp: /https?:\/\/.+/ }
onAccepted: login()
}
TextField {
id: userName
placeholderText: qsTr("username")
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 20
onAccepted: login()
}
TextField {
id: password
placeholderText: qsTr("password")
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 20
echoMode: TextInput.Password
onAccepted: login()
}
Button {
id: loginButton
text: "Ok"
anchors.right: parent.right
anchors.margins: 20
onClicked: login()
}
}
}

View file

@ -0,0 +1,89 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
Item {
property int textFontSize: 14
property int smallfontSize: 11
Component.onCompleted: fixFontSize()
onTextFontSizeChanged: fixFontSize()
function fixFontSize() {
smallfontSize = textFontSize * 0.8
}
id: item
height: column.height + 20
width: parent.parent.parent.width
Rectangle {
anchors.fill: parent
color: "transparent"
Rectangle {
anchors.fill: parent
anchors.leftMargin: 15
anchors.rightMargin: 15
anchors.topMargin: 10
anchors.bottomMargin: 10
color: "transparent"
Column {
id: column
width: parent.width
Row {
spacing: 10
Label {
text: feedTitle
font.pointSize: smallfontSize
textFormat: Text.PlainText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
}
Label {
text: date.toLocaleString(Qt.locale(), Locale.ShortFormat)
font.pointSize: smallfontSize
textFormat: Text.PlainText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
}
}
Label {
text: title
color: read ? "gray" : "black"
font.pointSize: textFontSize
textFormat: Text.RichText
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
width: parent.width
}
Label {
text: excerpt
font.pointSize: smallfontSize
textFormat: Text.RichText
color: "gray"
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
renderType: Text.NativeRendering
width: parent.width
}
}
}
Rectangle {
anchors.top: parent.bottom
width: parent.width
height: 1
color: "lightgray"
}
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.parent.parent.currentIndex = index
}
}
}

71
resources/qml/Sidebar.qml Normal file
View file

@ -0,0 +1,71 @@
import QtQuick 2.0
import TTRSS 1.0
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.3
ScrollView {
id: item
property Server server
property Content content
property Post previousPost
property int textFontSize: 14
style: ScrollViewStyle {
transientScrollBars: true
}
function next() {
if(listView.count > listView.currentIndex) {
listView.currentIndex++;
}
}
function previous() {
if(listView.currentIndex > 0) {
listView.currentIndex--;
}
}
ListView {
id: listView
focus: true
anchors.fill: parent
spacing: 1
model: item.server.posts
delegate: Component {
PostListItem {
textFontSize: item.textFontSize
}
}
highlightFollowsCurrentItem: false
highlight: Component {
Rectangle {
width: listView.currentItem.width
height: listView.currentItem.height
color: "lightblue"
opacity: 0.5
y: listView.currentItem.y
}
}
onCurrentItemChanged: {
if(previousPost) {
if(!previousPost.dontChangeRead) {
previousPost.read = true;
} else {
previousPost.dontChangeRead = false;
}
}
item.content.post = server.posts[currentIndex]
content.flickableItem.contentY = 0
previousPost = item.content.post
}
}
}

View file

@ -0,0 +1,99 @@
import QtQuick.Controls 1.2
import QtQuick 2.0
import TTRSS 1.0
MenuBar {
id: menuBar
property bool loggedIn: false
property ServerLogin serverLogin
property Server server
property Sidebar sidebar
property Content content
property bool visible: true
Menu {
visible: menuBar.visible
title: qsTr("File")
MenuItem {
text: qsTr("Exit")
shortcut: "Ctrl+Q"
onTriggered: Qt.quit()
}
}
Menu {
visible: menuBar.visible
title: qsTr("Action")
MenuItem {
text: qsTr("Reload")
shortcut: "R"
enabled: loggedIn
onTriggered: server.reload()
}
MenuItem {
text: qsTr("Set &Unread")
shortcut: "U"
enabled: loggedIn
onTriggered: {
content.post.dontChangeRead = true
content.post.read = false
}
}
MenuItem {
text: qsTr("Next")
shortcut: "J"
enabled: loggedIn
onTriggered: sidebar.next()
}
MenuItem {
text: qsTr("Previous")
shortcut: "K"
enabled: loggedIn
onTriggered: sidebar.previous()
}
MenuItem {
text: qsTr("Open in Browser")
shortcut: "N"
enabled: loggedIn
onTriggered: Qt.openUrlExternally(content.post.link)
}
MenuItem {
text: qsTr("Log Out")
enabled: loggedIn
onTriggered: serverLogin.logout()
}
}
Menu {
visible: menuBar.visible
title: qsTr("View")
MenuItem {
text: qsTr("Zoom In")
shortcut: "Ctrl++"
enabled: loggedIn
onTriggered: app.zoomIn()
}
MenuItem {
text: qsTr("Zoom Out")
shortcut: "Ctrl+-"
enabled: loggedIn
onTriggered: app.zoomOut()
}
MenuItem {
text: qsTr("Reset")
shortcut: "Ctrl+0"
enabled: loggedIn
onTriggered: app.zoomReset()
}
}
Menu {
visible: menuBar.visible
title: qsTr("Help")
MenuItem {
text: qsTr("About")
onTriggered: Qt.openUrlExternally("http://jabs.nu/feedthemonkey");
}
}
}

184
resources/qml/main.qml Normal file
View file

@ -0,0 +1,184 @@
import QtQuick 2.3
import QtQuick.Controls 1.3
import QtQuick.Window 2.0
import QtQuick.Layouts 1.1
import Qt.labs.settings 1.0
import TTRSS 1.0
ApplicationWindow {
id: app
title: "FeedTheMonkey"
visible: true
minimumWidth: 480
minimumHeight: 320
width: 800
height: 640
x: 200
y: 200
property Server server: server
property Sidebar sidebar: sidebar
property Content content: content
property variant fontSizes: [7,9,11,13,15,17,19,21,23,25,27,29,31]
property int defaultTextFontSizeIndex: 3
property int textFontSizeIndex: defaultTextFontSizeIndex
property int textFontSize: fontSizes[textFontSizeIndex]
Settings {
id: settings
category: "window"
property alias x: app.x
property alias y: app.y
property alias width: app.width
property alias height: app.height
property alias sidebarWidth: sidebar.width
property alias textFontSizeIndex: app.textFontSizeIndex
}
property TheMenuBar menu: TheMenuBar {
id: menu
serverLogin: serverLogin
server: server
sidebar: sidebar
content: content
}
function loggedIn() {
if(serverLogin.loggedIn()) {
menu.loggedIn = true;
contentView.visible = true
login.visible = false;
server.initialize(serverLogin.serverUrl, serverLogin.sessionId);
} else {
menu.loggedIn = false
contentView.visible = false
login.visible = true
server.loggedOut()
content.loggedOut()
}
}
function zoomIn() {
if(textFontSizeIndex + 1 < fontSizes.length) {
textFontSize = fontSizes[++textFontSizeIndex]
}
}
function zoomOut() {
if(textFontSizeIndex - 1 > 0) {
textFontSize = fontSizes[--textFontSizeIndex]
}
}
function zoomReset() {
textFontSizeIndex = defaultTextFontSizeIndex
textFontSize = fontSizes[textFontSizeIndex]
}
function keyPressed(event) {
switch (event.key) {
case Qt.Key_Right:
case Qt.Key_J:
case Qt.Key_j:
sidebar.next()
break
case Qt.Key_Left:
case Qt.Key_K:
case Qt.Key_k:
sidebar.previous()
break
case Qt.Key_Home:
content.scrollUp()
break
case Qt.Key_End:
content.scrollDown()
break
case Qt.Key_PageUp:
content.scrollUp(content.pageJump)
break
case Qt.Key_PageDown:
case Qt.Key_Space:
content.scrollDown(content.pageJump)
break
case Qt.Key_Down:
content.scrollDown(content.scrollJump)
break
case Qt.Key_Up:
content.scrollUp(content.scrollJump)
break
case Qt.Key_Enter:
case Qt.Key_Return:
Qt.openUrlExternally(content.post.link)
break
default:
break
}
}
SplitView {
id: contentView
anchors.fill: parent
orientation: Qt.Horizontal
visible: serverLogin.loggedIn()
focus: true
Sidebar {
id: sidebar
content: content
server: server
Layout.minimumWidth: 200
implicitWidth: 300
textFontSize: app.textFontSize
}
Content {
id: content
app: app
Layout.minimumWidth: 200
implicitWidth: 624
textFontSize: app.textFontSize
}
Keys.onPressed: keyPressed(event)
Keys.onReleased: {
switch (event.key) {
case Qt.Key_Alt:
app.menuBar = menu
break
default:
break
}
}
}
Login {
id: login
anchors.fill: parent
visible: !serverLogin.loggedIn()
function login() {
console.log("FOO")
serverLogin.login(serverUrl, userName, password)
}
}
ServerLogin {
id: serverLogin
onSessionIdChanged: app.loggedIn()
}
Server {
id: server
}
Component.onCompleted: {
if(serverLogin.loggedIn()) {
loggedIn();
}
}
}

20
resources/resources.qrc Normal file
View file

@ -0,0 +1,20 @@
<RCC>
<qresource prefix="">
<file>html/content.css</file>
<file>html/content.html</file>
<file>html/content.js</file>
</qresource>
<qresource prefix="">
<file>qml/main.qml</file>
<file>qml/TheMenuBar.qml</file>
<file>qml/Content.qml</file>
<file>qml/Login.qml</file>
<file>qml/PostListItem.qml</file>
<file>qml/Sidebar.qml</file>
</qresource>
<qresource prefix="">
<file>misc/feedthemonkey.xpm</file>
<file>misc/Icon.icns</file>
<file>misc/feedthemonkey.desktop</file>
</qresource>
</RCC>