Commit 4b3bd0be authored by Sébastien Blin's avatar Sébastien Blin

chatview: use common chatview code

Change-Id: Iaa2329c24eb740b57c19aaa45eb421e816747496
parent eb8317ad
[submodule "web"]
path = web
url = https://review.jami.net/jami-chatview
...@@ -444,6 +444,7 @@ load_javascript_libs(WebKitWebView *webview_chat, ...@@ -444,6 +444,7 @@ load_javascript_libs(WebKitWebView *webview_chat,
/* Create the list of libraries to load */ /* Create the list of libraries to load */
priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/jed.js"); priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/jed.js");
priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/linkify.js"); priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/linkify.js");
priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/chatview.js");
priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/linkify-string.js"); priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/linkify-string.js");
priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/linkify-html.js"); priv->js_libs_to_load = g_list_append(priv->js_libs_to_load, (gchar*) "/net/jami/JamiGnome/linkify-html.js");
...@@ -551,6 +552,22 @@ build_view(WebKitChatContainer *view) ...@@ -551,6 +552,22 @@ build_view(WebKitChatContainer *view)
); );
webkit_user_content_manager_add_style_sheet(webkit_content_manager, chatview_style_sheet); webkit_user_content_manager_add_style_sheet(webkit_content_manager, chatview_style_sheet);
chatview_style_sheet = webkit_user_style_sheet_new(
(gchar*) g_bytes_get_data(
g_resources_lookup_data(
"/net/jami/JamiGnome/chatview-gnome.css",
G_RESOURCE_LOOKUP_FLAGS_NONE,
NULL
),
NULL
),
WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
WEBKIT_USER_STYLE_LEVEL_USER,
NULL,
NULL
);
webkit_user_content_manager_add_style_sheet(webkit_content_manager, chatview_style_sheet);
/* Prepare WebKitSettings */ /* Prepare WebKitSettings */
WebKitSettings* webkit_settings = webkit_settings_new_with_settings( WebKitSettings* webkit_settings = webkit_settings_new_with_settings(
"enable-javascript", TRUE, "enable-javascript", TRUE,
......
web @ 0a790d86
Subproject commit 0a790d86a20ae80e5d2ee0d35452fa77cfb8cc40
{
"env": {
"browser": true
},
"plugins": ["html"],
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"never"
],
"no-inner-declarations": [
0
]
}
}
# README - chatview
The chatview runs under a WebKit GTK view. It is written using web technologies
(HTML5/CSS3/JS) and is responsible for displaying everything that deals with the
navbar, the messages, and the message bar.
## Contributing - syntax
We have a set of ESLint rules that define clear syntax rules (web/.eslintrc.json).
You will need the following tools:
- ESLint (The pluggable linting utility for JavaScript and JSX)
https://eslint.org/
- ESLint HTML plugin (eslint-plugin-html)
https://www.npmjs.com/package/eslint-plugin-html
Before pushing a patch, make sure that it passes ESLint:
$ eslint chatview.html
Most trivial issues can be fixed using
$ eslint chatview.html --fix
We will not accept patches introducing non-ESLint-compliant code.
## WebKit GTK
Everything runs under WebKit GTK, that is if you need to write browser specific
code, you will only need to support WebKit (CSS -webkit- prefix).
Do not use querySelector if getElementById or getElementByClassName can be used
instead. querySelector doesn't always make the code easier and has very bad
performances.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (c) 2016 SoapBox Innovations Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
'use strict';
;(function (window, linkify) {
var linkifyString = function (linkify) {
'use strict';
/**
Convert strings of text into linkable HTML text
*/
var tokenize = linkify.tokenize;
var options = linkify.options;
var Options = options.Options;
function escapeText(text) {
return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function escapeAttr(href) {
return href.replace(/"/g, '&quot;');
}
function attributesToString(attributes) {
if (!attributes) {
return '';
}
var result = [];
for (var attr in attributes) {
var val = attributes[attr] + '';
result.push(attr + '="' + escapeAttr(val) + '"');
}
return result.join(' ');
}
function linkifyStr(str) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts = new Options(opts);
var tokens = tokenize(str);
var result = [];
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type === 'nl' && opts.nl2br) {
result.push('<br>\n');
continue;
} else if (!token.isLink || !opts.check(token)) {
result.push(escapeText(token.toString()));
continue;
}
var _opts$resolve = opts.resolve(token);
var formatted = _opts$resolve.formatted;
var formattedHref = _opts$resolve.formattedHref;
var tagName = _opts$resolve.tagName;
var className = _opts$resolve.className;
var target = _opts$resolve.target;
var attributes = _opts$resolve.attributes;
var link = '<' + tagName + ' href="' + escapeAttr(formattedHref) + '"';
if (className) {
link += ' class="' + escapeAttr(className) + '"';
}
if (target) {
link += ' target="' + escapeAttr(target) + '"';
}
if (attributes) {
link += ' ' + attributesToString(attributes);
}
link += '>' + escapeText(formatted) + '</' + tagName + '>';
result.push(link);
}
return result.join('');
}
if (!String.prototype.linkify) {
String.prototype.linkify = function (opts) {
return linkifyStr(this, opts);
};
}
return linkifyStr;
}(linkify);
window.linkifyStr = linkifyString;
})(window, linkify);
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/net/jami/JamiGnome">
<!-- HTML -->
<file>chatview.html</file>
<!-- JavaScript -->
<file>linkify.js</file>
<file>linkify-string.js</file>
<file>linkify-html.js</file>
<file>jed.js</file>
<!-- CSS -->
<file>chatview.css</file>
<!-- Locale -->
</gresource>
</gresources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment