Browse Source
- Move the pubsub publish action to a new Widget
- Move the pubsub publish action to a new Widget
- Use it in the groups (not fully enabled yet) - Remove some old files - Fix minor issues in the chatpull/16/head
30 changed files with 389 additions and 232 deletions
-
6app/assets/js/movim_tpl.js
-
14app/models/presence/Presence.php
-
1app/views/group.tpl
-
1app/views/news.tpl
-
3app/widgets/Chats/Chats.php
-
3app/widgets/Chats/_chats_add.tpl
-
1app/widgets/Chats/_chats_add_extend.tpl
-
8app/widgets/Chats/_chats_item.tpl
-
2app/widgets/Contact/_contact.tpl
-
10app/widgets/Group/Group.php
-
2app/widgets/Group/_group_publish.tpl
-
3app/widgets/Groups/groups.js
-
1app/widgets/Menu/Menu.php
-
2app/widgets/Menu/_menu_add.tpl
-
103app/widgets/Post/Post.php
-
53app/widgets/Post/_post_create.tpl
-
27app/widgets/Post/_post_header_create.tpl
-
21app/widgets/Post/post.js
-
171app/widgets/Publish/Publish.php
-
54app/widgets/Publish/_publish_create.tpl
-
0app/widgets/Publish/_publish_embed.tpl
-
0app/widgets/Publish/_publish_gallery.tpl
-
45app/widgets/Publish/_publish_header.tpl
-
0app/widgets/Publish/_publish_help.tpl
-
0app/widgets/Publish/_publish_preview.tpl
-
20app/widgets/Publish/locales.ini
-
21app/widgets/Publish/publish.js
-
0app/widgets/Publish/publish.tpl
-
14app/widgets/Rooms/_rooms_list.tpl
-
35linker.php
@ -1,3 +1,3 @@ |
|||
<a onclick="Group_ajaxPublish()" class="button action color"> |
|||
<a onclick="Publish_ajaxCreate('{$server}','{$node}')" class="button action color"> |
|||
<i class="md md-create"></i> |
|||
</a> |
@ -1,3 +1,3 @@ |
|||
<a onclick="Post_ajaxCreate(); MovimTpl.showPanel();" class="button action color red"> |
|||
<a onclick="Publish_ajaxCreate('{$to}', 'urn:xmpp:microblog:0'); MovimTpl.showPanel();" class="button action color red"> |
|||
<i class="md md-create"></i> |
|||
</a> |
@ -1,53 +0,0 @@ |
|||
<form name="post" class="padded_top_bottom"> |
|||
<input type="hidden" name="to" value="{$to}"> |
|||
<input type="hidden" name="node" value="urn:xmpp:microblog:0"> |
|||
<div> |
|||
<input type="text" name="title" placeholder="{$c->__('post.title')}"> |
|||
<label for="title">{$c->__('post.title')}</label> |
|||
</div> |
|||
<div> |
|||
<textarea name="content" placeholder="{$c->__('post.content')}" onkeyup="movim_textarea_autoheight(this);"></textarea> |
|||
<label for="content">{$c->__('post.content')}</label> |
|||
</div> |
|||
<div> |
|||
<input |
|||
type="url" |
|||
name="embed" |
|||
placeholder="http://myawesomewebsite.com/ or http://mynicepictureurl.com/" |
|||
onPaste="var e=this; setTimeout(function(){Post_ajaxEmbedTest(e.value);}, 4);" |
|||
> |
|||
<label for="embed">{$c->__('post.link')}</label> |
|||
<ul class="middle flex active"> |
|||
<li class="subheader">{$c->__('post.embed_tip')}</li> |
|||
<a class="block" target="_blank" href="http://imgur.com/"> |
|||
<li class="block action"> |
|||
<div class="action"> |
|||
<i class="md md-chevron-right"></i> |
|||
</div> |
|||
<span class="bubble icon"> |
|||
<img src="https://userecho.com/s/logos/2015/2015.png"> |
|||
</span> |
|||
Imgur |
|||
</li> |
|||
</a> |
|||
<a class="block" target="_blank" href="https://www.flickr.com/"> |
|||
<li class="action"> |
|||
<div class="action"> |
|||
<i class="md md-chevron-right"></i> |
|||
</div> |
|||
<span class="bubble icon"> |
|||
<img src="https://www.flickr.com/apple-touch-icon.png"> |
|||
</span> |
|||
Flickr |
|||
</li> |
|||
</a> |
|||
</ul> |
|||
|
|||
<article> |
|||
<section> |
|||
<content id="preview"></content> |
|||
</section> |
|||
</article> |
|||
<div id="gallery"></div> |
|||
</div> |
|||
</form> |
@ -1,27 +0,0 @@ |
|||
<div> |
|||
<span class="on_desktop icon"><i class="md md-view-list"></i></span> |
|||
<h2>{$c->__('page.news')}</h2> |
|||
</div> |
|||
<div> |
|||
<div class="return active r3" onclick="MovimTpl.hidePanel(); Post_ajaxClear();"> |
|||
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span> |
|||
<h2>{$c->__('post.new')}</h2> |
|||
</div> |
|||
<ul class="active"> |
|||
<li onclick="Post_ajaxHelp()"> |
|||
<span class="icon"> |
|||
<i class="md md-help"></i> |
|||
</span> |
|||
</li> |
|||
<li onclick="Post_ajaxPreview(movim_form_to_json('post'))"> |
|||
<span class="icon"> |
|||
<i class="md md-remove-red-eye"></i> |
|||
</span> |
|||
</li> |
|||
<li onclick="Post_ajaxPublish(movim_form_to_json('post'))"> |
|||
<span class="icon"> |
|||
<i class="md md-send"></i> |
|||
</span> |
|||
</li> |
|||
</ul> |
|||
</div> |
@ -1,21 +0,0 @@ |
|||
var Post = { |
|||
init: function() { |
|||
if(localStorage.getItem('share_url')) { |
|||
Post_ajaxCreate(); |
|||
MovimTpl.showPanel(); |
|||
} |
|||
}, |
|||
|
|||
setEmbed: function() { |
|||
if(localStorage.getItem('share_url')) { |
|||
var embed = document.querySelector('input[name=embed]'); |
|||
embed.value = localStorage.getItem('share_url'); |
|||
embed.onpaste(); |
|||
localStorage.removeItem('share_url'); |
|||
} |
|||
} |
|||
} |
|||
|
|||
MovimWebsocket.attach(function() { |
|||
Post.init(); |
|||
}); |
@ -0,0 +1,171 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* @package Widgets |
|||
* |
|||
* @file Post.php |
|||
* This file is part of Movim. |
|||
* |
|||
* @brief The Post visualisation widget |
|||
* |
|||
* @author Jaussoin Timothée <edhelas_at_movim_dot_com> |
|||
* |
|||
* @version 1.0 |
|||
* @date 1 december 2014 |
|||
* |
|||
* Copyright (C)2014 MOVIM project |
|||
* |
|||
* See COPYING for licensing information. |
|||
*/ |
|||
|
|||
use Moxl\Xec\Action\Pubsub\PostPublish; |
|||
use Moxl\Xec\Action\Microblog\CommentCreateNode; |
|||
use \Michelf\Markdown; |
|||
use Respect\Validation\Validator; |
|||
|
|||
class Publish extends WidgetCommon |
|||
{ |
|||
function load() |
|||
{ |
|||
$this->addjs('publish.js'); |
|||
$this->registerEvent('pubsub_publishpublish_handle', 'onPublish'); |
|||
} |
|||
|
|||
function onPublish($packet) |
|||
{ |
|||
list($to, $node, $id) = array_values($packet->content); |
|||
|
|||
// Only for the microblog for the moment
|
|||
if($node == 'urn:xmpp:microblog:0') { |
|||
$cn = new CommentCreateNode; |
|||
$cn->setTo($to) |
|||
->setParentId($id) |
|||
->request(); |
|||
} |
|||
} |
|||
|
|||
function ajaxCreateBlog() |
|||
{ |
|||
$this->ajaxCreate($this->user->getLogin(), 'urn:xmpp:microblog:0'); |
|||
} |
|||
|
|||
function ajaxCreate($server, $node) |
|||
{ |
|||
if(!$this->validateServerNode($server, $node)) return; |
|||
|
|||
$view = $this->tpl(); |
|||
$view->assign('to', $server); |
|||
$view->assign('node', $node); |
|||
RPC::call('MovimTpl.fill', 'main section > div:nth-child(2)', $view->draw('_publish_create', true)); |
|||
|
|||
$pd = new \Modl\ItemDAO; |
|||
$item = $pd->getItem($server, $node); |
|||
|
|||
$view = $this->tpl(); |
|||
$view->assign('item', $item); |
|||
$view->assign('server', $server); |
|||
$view->assign('node', $node); |
|||
Header::fill($view->draw('_publish_header', true)); |
|||
|
|||
RPC::call('Publish.setEmbed'); |
|||
} |
|||
|
|||
function ajaxPreview($form) |
|||
{ |
|||
if($form->content->value != '') { |
|||
$view = $this->tpl(); |
|||
$view->assign('content', Markdown::defaultTransform($form->content->value)); |
|||
|
|||
Dialog::fill($view->draw('_publish_preview', true), true); |
|||
} else { |
|||
Notification::append(false, $this->__('publish.no_content_preview')); |
|||
} |
|||
} |
|||
|
|||
function ajaxHelp() |
|||
{ |
|||
$view = $this->tpl(); |
|||
Dialog::fill($view->draw('_publish_help', true), true); |
|||
} |
|||
|
|||
function ajaxPublish($form) |
|||
{ |
|||
if($form->content->value != '') { |
|||
$content = Markdown::defaultTransform($form->content->value); |
|||
|
|||
$p = new PostPublish; |
|||
$p->setFrom($this->user->getLogin()) |
|||
->setTo($form->to->value) |
|||
->setNode($form->node->value); |
|||
//->setLocation($geo)
|
|||
//->enableComments()
|
|||
if($form->title->value != '') { |
|||
$p->setTitle($form->title->value); |
|||
} |
|||
|
|||
if($form->embed->value != '' && filter_var($form->embed->value, FILTER_VALIDATE_URL)) { |
|||
$embed = Embed\Embed::create($form->embed->value); |
|||
$content .= $this->prepareEmbed($embed); |
|||
$p->setLink($form->embed->value); |
|||
|
|||
if($embed->type == 'photo') { |
|||
$key = key($embed->images); |
|||
$p->setImage($embed->images[0]['value'], $embed->title, $embed->images[0]['mime']); |
|||
} |
|||
} |
|||
|
|||
$p->setContentHtml(rawurldecode($content)) |
|||
->request(); |
|||
} else { |
|||
Notification::append(false, $this->__('publish.no_content')); |
|||
} |
|||
} |
|||
|
|||
function ajaxEmbedTest($url) |
|||
{ |
|||
if($url == '') { |
|||
return; |
|||
} elseif(!filter_var($url, FILTER_VALIDATE_URL)) { |
|||
Notification::append(false, $this->__('publish.valid_url')); |
|||
return; |
|||
} |
|||
|
|||
$embed = Embed\Embed::create($url); |
|||
$html = $this->prepareEmbed($embed); |
|||
|
|||
if($embed->type == 'photo') { |
|||
RPC::call('movim_fill', 'gallery', $this->prepareGallery($embed)); |
|||
} |
|||
|
|||
RPC::call('movim_fill', 'preview', $html); |
|||
} |
|||
|
|||
function prepareEmbed($embed) |
|||
{ |
|||
$view = $this->tpl(); |
|||
$view->assign('embed', $embed); |
|||
return $view->draw('_publish_embed', true); |
|||
} |
|||
|
|||
function prepareGallery($embed) |
|||
{ |
|||
$view = $this->tpl(); |
|||
$view->assign('embed', $embed); |
|||
return $view->draw('_publish_gallery', true); |
|||
} |
|||
|
|||
private function validateServerNode($server, $node) |
|||
{ |
|||
$validate_server = Validator::string()->noWhitespace()->length(6, 40); |
|||
$validate_node = Validator::string()->length(3, 100); |
|||
|
|||
if(!$validate_server->validate($server) |
|||
|| !$validate_node->validate($node) |
|||
) return false; |
|||
else return true; |
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
<form name="post" class="padded_top_bottom"> |
|||
<input type="hidden" name="to" value="{$to}"> |
|||
<input type="hidden" name="node" value="{$node}"> |
|||
<div> |
|||
<input type="text" name="title" placeholder="{$c->__('post.title')}"> |
|||
<label for="title">{$c->__('post.title')}</label> |
|||
</div> |
|||
<div> |
|||
<textarea name="content" placeholder="{$c->__('post.content')}" onkeyup="movim_textarea_autoheight(this);"></textarea> |
|||
<label for="content">{$c->__('post.content')}</label> |
|||
</div> |
|||
<div> |
|||
<input |
|||
type="url" |
|||
name="embed" |
|||
placeholder="http://myawesomewebsite.com/ or http://mynicepictureurl.com/" |
|||
onPaste="var e=this; setTimeout(function(){Publish_ajaxEmbedTest(e.value);}, 4);" |
|||
> |
|||
<label for="embed">{$c->__('post.link')}</label> |
|||
|
|||
<article> |
|||
<section> |
|||
<content id="preview"></content> |
|||
</section> |
|||
</article> |
|||
<div id="gallery"></div> |
|||
</div> |
|||
|
|||
<ul class="middle flex active"> |
|||
<li class="subheader">{$c->__('post.embed_tip')}</li> |
|||
<a class="block" target="_blank" href="http://imgur.com/"> |
|||
<li class="block action"> |
|||
<div class="action"> |
|||
<i class="md md-chevron-right"></i> |
|||
</div> |
|||
<span class="bubble icon"> |
|||
<img src="https://userecho.com/s/logos/2015/2015.png"> |
|||
</span> |
|||
Imgur |
|||
</li> |
|||
</a> |
|||
<a class="block" target="_blank" href="https://www.flickr.com/"> |
|||
<li class="action"> |
|||
<div class="action"> |
|||
<i class="md md-chevron-right"></i> |
|||
</div> |
|||
<span class="bubble icon"> |
|||
<img src="https://www.flickr.com/apple-touch-icon.png"> |
|||
</span> |
|||
Flickr |
|||
</li> |
|||
</a> |
|||
</ul> |
|||
</form> |
@ -0,0 +1,45 @@ |
|||
<div> |
|||
<span class="on_desktop icon"><i class="md md-create"></i></span> |
|||
<h2>{$c->__('publish.title')}</h2> |
|||
</div> |
|||
<div> |
|||
<div class="return active r3 condensed" |
|||
onclick=" |
|||
if(typeof Post_ajaxClear === 'function') { |
|||
Post_ajaxClear(); |
|||
Header_ajaxReset('news'); |
|||
} else { |
|||
Group_ajaxGetItems('{$server}', '{$node}'); |
|||
}"> |
|||
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span> |
|||
<h2>{$c->__('publish.new')}</h2> |
|||
<h4> |
|||
{if="$item != null"} |
|||
{if="$item->name"} |
|||
{$item->name} |
|||
{else} |
|||
{$item->node} |
|||
{/if} |
|||
{else} |
|||
{$c->__('page.blog')} |
|||
{/if} |
|||
</h4> |
|||
</div> |
|||
<ul class="active"> |
|||
<li onclick="Publish_ajaxHelp()"> |
|||
<span class="icon"> |
|||
<i class="md md-help"></i> |
|||
</span> |
|||
</li> |
|||
<li onclick="Publish_ajaxPreview(movim_form_to_json('post'))"> |
|||
<span class="icon"> |
|||
<i class="md md-remove-red-eye"></i> |
|||
</span> |
|||
</li> |
|||
<li onclick="Publish_ajaxPublish(movim_form_to_json('post'))"> |
|||
<span class="icon"> |
|||
<i class="md md-send"></i> |
|||
</span> |
|||
</li> |
|||
</ul> |
|||
</div> |
@ -0,0 +1,20 @@ |
|||
post.news_feed = 'News Feed' |
|||
post.placeholder = 'Discover and register to the groups you are interested in' |
|||
post.preview = 'Preview' |
|||
post.help = 'Help' |
|||
post.help_more = 'More help' |
|||
post.help_manual = 'Markdown syntax manual' |
|||
post.title = 'Title' |
|||
post.content = 'Content' |
|||
post.link = 'Link' |
|||
post.tags = 'Tags' |
|||
publish.valid_url = 'Please enter a valid url' |
|||
publish.no_content_preview = 'No content to preview' |
|||
publish.no_content = 'No content' |
|||
post.published = 'Post published' |
|||
post.deleted = 'Post deleted' |
|||
post.gallery = 'This picture will be added to your gallery' |
|||
post.hot = "What's Hot" |
|||
publish.new = 'New post' |
|||
publish.title = 'Publish' |
|||
post.embed_tip = 'You can also use services like Imgur or Flickr to host your picture and paste the link here.' |
@ -0,0 +1,21 @@ |
|||
var Publish = { |
|||
init: function() { |
|||
if(localStorage.getItem('share_url')) { |
|||
Publish_ajaxCreateBlog(); |
|||
MovimTpl.showPanel(); |
|||
} |
|||
}, |
|||
|
|||
setEmbed: function() { |
|||
if(localStorage.getItem('share_url')) { |
|||
var embed = document.querySelector('input[name=embed]'); |
|||
embed.value = localStorage.getItem('share_url'); |
|||
embed.onpaste(); |
|||
localStorage.removeItem('share_url'); |
|||
} |
|||
} |
|||
} |
|||
|
|||
MovimWebsocket.attach(function() { |
|||
Publish.init(); |
|||
}); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue