Userscript iFrame
This commit is contained in:
@@ -8,7 +8,7 @@ var NotificationBase = new Class({
|
||||
self.setOptions(options);
|
||||
|
||||
// Listener
|
||||
App.addEvent('load', self.request.bind(self));
|
||||
App.addEvent('load', self.startInterval.bind(self));
|
||||
self.addEvent('notification', self.notify.bind(self))
|
||||
|
||||
// Add test buttons to settings page
|
||||
@@ -16,15 +16,25 @@ var NotificationBase = new Class({
|
||||
|
||||
},
|
||||
|
||||
request: function(){
|
||||
startInterval: function(){
|
||||
var self = this;
|
||||
|
||||
Api.request('core_notifier.listener', {
|
||||
self.request = Api.request('core_notifier.listener', {
|
||||
'initialDelay': 100,
|
||||
'delay': 3000,
|
||||
'onComplete': self.processData.bind(self)
|
||||
}).startTimer()
|
||||
})
|
||||
|
||||
self.request.startTimer()
|
||||
|
||||
},
|
||||
|
||||
startTimer: function(){
|
||||
this.request.startTimer()
|
||||
},
|
||||
|
||||
stopTimer: function(){
|
||||
this.request.stopTimer()
|
||||
},
|
||||
|
||||
notify: function(data){
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* @override
|
||||
/* @override
|
||||
http://localhost:5000/static/movie_plugin/search.css
|
||||
http://192.168.1.20:5000/static/movie_plugin/search.css
|
||||
http://127.0.0.1:5000/static/movie_plugin/search.css
|
||||
@@ -8,8 +8,8 @@
|
||||
display: inline-block;
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.search_form input {
|
||||
|
||||
.search_form input {
|
||||
padding-right: 25px;
|
||||
padding: 4px;
|
||||
margin: 0;
|
||||
@@ -26,18 +26,18 @@
|
||||
background: url('../images/checks.png') right -36px no-repeat;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.search_form .results_container {
|
||||
position: absolute;
|
||||
background: #5c697b;
|
||||
margin: 6px 0 0 -246px;
|
||||
width: 470px;
|
||||
min-height: 140px;
|
||||
|
||||
|
||||
border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
|
||||
|
||||
box-shadow: 0 0 50px rgba(0,0,0,0.55);
|
||||
-moz-box-shadow: 0 0 50px rgba(0,0,0,0.55);
|
||||
-webkit-box-shadow: 0 0 50px rgba(0,0,0,0.55);
|
||||
@@ -45,7 +45,7 @@
|
||||
.search_form .spinner {
|
||||
background: rgba(0,0,0,0.8) url('../images/spinner.gif') no-repeat center 70px;
|
||||
}
|
||||
|
||||
|
||||
.search_form .pointer {
|
||||
border-right: 10px solid transparent;
|
||||
border-left: 10px solid transparent;
|
||||
@@ -56,19 +56,19 @@
|
||||
left: 50%;
|
||||
margin: -9px 0 0 110px;
|
||||
}
|
||||
|
||||
|
||||
.search_form .results {
|
||||
max-height: 550px;
|
||||
overflow-x: hidden;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.search_form .results .movie {
|
||||
|
||||
.movie_result {
|
||||
overflow: hidden;
|
||||
min-height: 140px;
|
||||
}
|
||||
|
||||
.search_form .results .movie .options {
|
||||
|
||||
.movie_result .options {
|
||||
height: 139px;
|
||||
border: 1px solid transparent;
|
||||
border-width: 1px 0;
|
||||
@@ -79,38 +79,38 @@
|
||||
-moz-box-shadow: inset 0 1px 8px rgba(0,0,0,0.25);
|
||||
-webkit-box-shadow: inset 0 1px 8px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
.search_form .results .movie .options > div {
|
||||
|
||||
.movie_result .options > div {
|
||||
padding: 0 15px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.search_form .results .movie .options .thumbnail {
|
||||
|
||||
.movie_result .options .thumbnail {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.search_form .results .movie .options select {
|
||||
|
||||
.movie_result .options select {
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.search_form .results .movie .options select[name=title] { width: 180px; }
|
||||
.search_form .results .movie .options select[name=profile] { width: 90px; }
|
||||
|
||||
.search_form .results .movie .options .button {
|
||||
.movie_result .options select[name=title] { width: 180px; }
|
||||
.movie_result .options select[name=profile] { width: 90px; }
|
||||
|
||||
.movie_result .options .button {
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.search_form .results .movie .options .message {
|
||||
|
||||
.movie_result .options .message {
|
||||
height: 100%;
|
||||
line-height: 140px;
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.search_form .results .movie .data {
|
||||
|
||||
.movie_result .data {
|
||||
padding: 0 15px;
|
||||
width: 440px;
|
||||
position: relative;
|
||||
@@ -120,19 +120,19 @@
|
||||
min-height: 140px;
|
||||
background: #5c697b;
|
||||
cursor: pointer;
|
||||
|
||||
|
||||
border-bottom: 1px solid #333;
|
||||
border-top: 1px solid rgba(255,255,255, 0.15);
|
||||
}
|
||||
|
||||
.search_form .results .movie:last-child .data { border-bottom: 0; }
|
||||
|
||||
.search_form .results .movie .thumbnail {
|
||||
.movie_result:last-child .data { border-bottom: 0; }
|
||||
|
||||
.movie_result .thumbnail {
|
||||
width: 17%;
|
||||
display: inline-block;
|
||||
margin: 15px 3% 15px 0;
|
||||
vertical-align: top;
|
||||
|
||||
|
||||
border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
@@ -140,32 +140,32 @@
|
||||
-moz-box-shadow: 0 0 3px rgba(0,0,0,0.35);
|
||||
-webkit-box-shadow: 0 0 3px rgba(0,0,0,0.35);
|
||||
}
|
||||
|
||||
.search_form .results .movie .info {
|
||||
|
||||
.movie_result .info {
|
||||
width: 74%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
padding: 15px 0;
|
||||
}
|
||||
|
||||
.search_form .results .movie .info .tagline {
|
||||
|
||||
.movie_result .info .tagline {
|
||||
max-height: 70px;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.search_form .results .movie .add +.info {
|
||||
.movie_result .add +.info {
|
||||
margin-left: 20%;
|
||||
}
|
||||
|
||||
.search_form .results .movie .info h2 {
|
||||
|
||||
.movie_result .info h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.search_form .results .movie .info h2 span {
|
||||
|
||||
.movie_result .info h2 span {
|
||||
padding: 0 5px;
|
||||
content: ")";
|
||||
}
|
||||
|
||||
.search_form .results .movie .info h2 span:before { content: "("; }
|
||||
.search_form .results .movie .info h2 span:after { content: ")"; }
|
||||
|
||||
.movie_result .info h2 span:before { content: "("; }
|
||||
.movie_result .info h2 span:after { content: ")"; }
|
||||
|
||||
@@ -167,7 +167,7 @@ Block.Search.Item = new Class({
|
||||
|
||||
var info = self.info;
|
||||
|
||||
self.el = new Element('div.movie', {
|
||||
self.el = new Element('div.movie_result', {
|
||||
'id': info.imdb
|
||||
}).adopt(
|
||||
self.options = new Element('div.options.inlay'),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from .main import Extension
|
||||
from .main import Userscript
|
||||
|
||||
def start():
|
||||
return Extension()
|
||||
return Userscript()
|
||||
|
||||
config = []
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from couchpotato import index
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.helpers.request import getParam, jsonified
|
||||
@@ -10,12 +11,12 @@ from flask.helpers import url_for
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Extension(Plugin):
|
||||
class Userscript(Plugin):
|
||||
|
||||
def __init__(self):
|
||||
addApiView('userscript', self.getExtension)
|
||||
|
||||
addApiView('userscript.add_via_url', self.addViaUrl)
|
||||
addApiView('userscript.get', self.getExtension)
|
||||
addApiView('userscript', self.iFrame)
|
||||
addApiView('userscript.add_via_url', self.getViaUrl)
|
||||
|
||||
def getExtension(self):
|
||||
|
||||
@@ -38,9 +39,8 @@ class Extension(Plugin):
|
||||
|
||||
return version
|
||||
|
||||
def addViaUrl(self):
|
||||
url = getParam('url')
|
||||
return self.renderTemplate(__file__, 'iframe.html', url = url)
|
||||
def iFrame(self):
|
||||
return index()
|
||||
|
||||
def getViaUrl(self):
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
.page.userscript {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.page.userscript .frame.loading {
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
Page.Userscript = new Class({
|
||||
|
||||
Extends: PageBase,
|
||||
|
||||
name: 'userscript',
|
||||
has_tab: false,
|
||||
|
||||
options: {
|
||||
'onOpened': function(){
|
||||
App.stopLoadTimer();
|
||||
App.getBlock('header').hide();
|
||||
}
|
||||
},
|
||||
|
||||
indexAction: function(param){
|
||||
var self = this;
|
||||
|
||||
self.el.adopt(
|
||||
self.frame = new Element('div.frame.loading', {
|
||||
'text': 'Loading...'
|
||||
})
|
||||
);
|
||||
|
||||
var url = window.location.href.split('url=')[1];
|
||||
|
||||
Api.request('userscript.add_via_url', {
|
||||
'data': {
|
||||
'url': url
|
||||
},
|
||||
'onComplete': function(json){
|
||||
self.frame.empty();
|
||||
self.frame.removeClass('loading');
|
||||
|
||||
if(json.error)
|
||||
self.frame.set('html', json.error);
|
||||
else {
|
||||
var item = new Block.Search.Item(json.movie);
|
||||
self.frame.adopt(item);
|
||||
item.showOptions();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -11,6 +11,7 @@ var BlockBase = new Class({
|
||||
self.page = parent;
|
||||
|
||||
self.create();
|
||||
|
||||
},
|
||||
|
||||
create: function(){
|
||||
@@ -20,6 +21,14 @@ var BlockBase = new Class({
|
||||
getParent: function(){
|
||||
return this.page
|
||||
},
|
||||
|
||||
hide: function(){
|
||||
this.el.hide();
|
||||
},
|
||||
|
||||
show: function(){
|
||||
this.el.show();
|
||||
},
|
||||
|
||||
toElement: function(){
|
||||
return this.el
|
||||
@@ -27,4 +36,4 @@ var BlockBase = new Class({
|
||||
|
||||
});
|
||||
|
||||
var Block = {}
|
||||
var Block = BlockBase
|
||||
@@ -31,7 +31,7 @@ var CouchPotato = new Class({
|
||||
|
||||
self.c.addEvent('click:relay(a:not([target=_blank]))', self.pushState.bind(self));
|
||||
},
|
||||
|
||||
|
||||
getOption: function(name){
|
||||
return this.options[name];
|
||||
},
|
||||
@@ -48,8 +48,10 @@ var CouchPotato = new Class({
|
||||
createLayout: function(){
|
||||
var self = this;
|
||||
|
||||
self.block.header = new Block();
|
||||
|
||||
self.c.adopt(
|
||||
self.header = new Element('div.header').adopt(
|
||||
$(self.block.header).addClass('header').adopt(
|
||||
new Element('div').adopt(
|
||||
self.block.navigation = new Block.Navigation(self, {}),
|
||||
self.block.search = new Block.Search(self, {})
|
||||
@@ -70,9 +72,16 @@ var CouchPotato = new Class({
|
||||
$(pg).inject(self.content);
|
||||
});
|
||||
|
||||
self.fireEvent('load')
|
||||
self.load_timer = (function(){
|
||||
self.fireEvent('load');
|
||||
}).delay(1000);
|
||||
|
||||
},
|
||||
|
||||
stopLoadTimer: function(){
|
||||
if(this.load_timer)
|
||||
clearInterval(this.load_timer);
|
||||
},
|
||||
|
||||
openPage: function(url) {
|
||||
var self = this;
|
||||
@@ -132,7 +141,8 @@ var Route = new Class({
|
||||
parse: function(url_string){
|
||||
var self = this;
|
||||
|
||||
var current = History.getPath().replace(/^\/+|\/+$/g, '')
|
||||
var path = History.getPath().replace(Api.getOption('url'), '/') //Remove API front
|
||||
var current = path.replace(/^\/+|\/+$/g, '')
|
||||
var url = current.split('/')
|
||||
|
||||
self.page = (url.length > 0) ? url.shift() : self.defaults.page
|
||||
|
||||
@@ -7,6 +7,7 @@ var PageBase = new Class({
|
||||
},
|
||||
|
||||
has_tab: true,
|
||||
name: '',
|
||||
|
||||
initialize: function(options) {
|
||||
var self = this;
|
||||
|
||||
@@ -1,45 +1,46 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='style/main.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='style/uniform.generic.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='style/uniform.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('web.static', filename='style/main.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('web.static', filename='style/uniform.generic.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('web.static', filename='style/uniform.css') }}" type="text/css">
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='style/page/settings.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('.static', filename='style/page/wanted.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('web.static', filename='style/page/settings.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('web.static', filename='style/page/wanted.css') }}" type="text/css">
|
||||
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/mootools.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/mootools_more.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/mootools.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/mootools_more.js') }}"></script>
|
||||
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/templated.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/uniform.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/form_replacement/form_check.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/form_replacement/form_radio.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/form_replacement/form_dropdown.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/form_replacement/form_selectoption.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/question.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/templated.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/uniform.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/form_replacement/form_check.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/form_replacement/form_radio.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/form_replacement/form_dropdown.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/form_replacement/form_selectoption.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/question.js') }}"></script>
|
||||
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/couchpotato.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/library/history.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/couchpotato.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/api.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/library/history.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/page.js') }}"></script>
|
||||
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/block.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/block/navigation.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/block/footer.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/block.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/block/navigation.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/block/footer.js') }}"></script>
|
||||
|
||||
{% for url in fireEvent('clientscript.get_scripts', as_html = True, single = True) %}
|
||||
<script type="text/javascript" src="{{ url_for('web.index') }}{{ url }}"></script>{% endfor %}
|
||||
{% for url in fireEvent('clientscript.get_styles', as_html = True, single = True) %}
|
||||
<link rel="stylesheet" href="{{ url_for('web.index') }}{{ url }}" type="text/css">{% endfor %}
|
||||
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/wanted.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/settings.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/about.js') }}"></script>
|
||||
<!--<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/soon.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('.static', filename='scripts/page/manage.js') }}"></script>-->
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/page/wanted.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/page/settings.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/page/about.js') }}"></script>
|
||||
<!--<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/page/soon.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('web.static', filename='scripts/page/manage.js') }}"></script>-->
|
||||
|
||||
<link href="{{ url_for('.static', filename='images/favicon.ico') }}" rel="icon" type="image/x-icon" />
|
||||
<link rel="apple-touch-icon" href="{{ url_for('.static', filename='images/homescreen.png') }}" />
|
||||
<link href="{{ url_for('web.static', filename='images/favicon.ico') }}" rel="icon" type="image/x-icon" />
|
||||
<link rel="apple-touch-icon" href="{{ url_for('web.static', filename='images/homescreen.png') }}" />
|
||||
|
||||
<script type="text/javascript">
|
||||
window.addEvent('domready', function() {
|
||||
|
||||
Reference in New Issue
Block a user