forked from zhukov/webogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
86 lines (77 loc) · 2.57 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*!
* Webogram v0.4.2 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
* https://github.com/zhukov/webogram/blob/master/LICENSE
*/
'use strict';
// Declare app level module which depends on filters, and services
angular.module('myApp', [
'ngRoute',
'ngSanitize',
'ngTouch',
'ui.bootstrap',
'mediaPlayer',
'izhukov.utils',
'izhukov.mtproto',
'izhukov.mtproto.wrapper',
'myApp.filters',
'myApp.services',
/*PRODUCTION_ONLY_BEGIN
'myApp.templates',
PRODUCTION_ONLY_END*/
'myApp.directives',
'myApp.controllers',
'hc.marked'
]).
config(['$locationProvider', '$routeProvider', '$compileProvider', 'StorageProvider', 'markedProvider', function($locationProvider, $routeProvider, $compileProvider, StorageProvider, markedProvider) {
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob|filesystem|chrome-extension|app):|data:image\//);
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|file|mailto|blob|filesystem|chrome-extension|app):|data:/);
if (Config.Modes.test) {
StorageProvider.setPrefix('t_');
}
$routeProvider.when('/', {templateUrl: templateUrl('welcome'), controller: 'AppWelcomeController'});
$routeProvider.when('/login', {templateUrl: templateUrl('login'), controller: 'AppLoginController'});
$routeProvider.when('/im', {templateUrl: templateUrl('im'), controller: 'AppIMController', reloadOnSearch: false});
$routeProvider.otherwise({redirectTo: '/'});
// Fixing the enclosing <p> issue
// https://github.com/chjj/marked/issues/576
var markedRenderer = new marked.Renderer() ;
markedRenderer.paragraph = function(text) {
return text + '\n';
};
// Add target='_blank to links'
markedRenderer.link = function(href, title, text) {
if (this.options.sanitize) {
try {
var prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return '';
}
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
return '';
}
}
var out = '<a href="' + href + '" target="_blank"';
if (title) {
out += ' title="' + title + '"';
}
out += '>' + text + '</a>';
return out;
};
markedProvider.setOptions({
renderer: markedRenderer,
gfm: true,
tables: true,
breaks: true,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
highlight: function (code) {
return hljs.highlightAuto(code).value;
}
});
}]);