Browse Source

Use the picture grid for attached post pictures

Set proper page title when loading posts or communities
Update the dependencies
pull/978/head
Timothée Jaussoin 5 years ago
parent
commit
e1e33c275f
  1. 5
      app/Info.php
  2. 10
      app/widgets/CommunitiesServer/CommunitiesServer.php
  3. 24
      app/widgets/CommunityData/CommunityData.php
  4. 2
      app/widgets/Post/Post.php
  5. 36
      app/widgets/Post/_post.tpl
  6. 2
      app/widgets/Post/_post_links.tpl
  7. 64
      composer.lock
  8. 3
      public/scripts/movim_utils.js

5
app/Info.php

@ -19,7 +19,10 @@ class Info extends Model
public function save(array $options = [])
{
// Empty features, we're not saving anything
if (is_array($this->attributes['features']) && empty($this->attributes['features'])) return;
if (array_key_exists('features', $this->attributes)
&& is_array($this->attributes['features'])
&& empty($this->attributes['features'])
) return;
try {
unset($this->identities);

10
app/widgets/CommunitiesServer/CommunitiesServer.php

@ -116,16 +116,20 @@ class CommunitiesServer extends \Movim\Widget\Base
public function prepareCommunitiesServer($origin)
{
$item = \App\Info::where('server', $origin)->where('node', '')->first();
$view = $this->tpl();
$view->assign('item', \App\Info::where('server', $origin)
->where('node', '')
->first());
$view->assign('item', $item);
$view->assign('nodes', \App\Info::where('server', $origin)
->where('node', '!=', '')
->orderBy('occupants', 'desc')
->get());
$view->assign('server', $origin);
if (isset($item->name)) {
$this->rpc('MovimUtils.setTitle', $this->__('page.communities') . ' • ' . $item->name);
}
return $view->draw('_communitiesserver');
}

24
app/widgets/CommunityData/CommunityData.php

@ -42,13 +42,23 @@ class CommunityData extends Base
->first();
$view->assign('info', $info);
$view->assign('num', $info ?
($info->items > 0)
? $info->items
: \App\Post::where('server', $origin)
->where('node', $node)
->count()
: 0);
$view->assign('num', 0);
if ($info) {
$view->assign('num',
($info->items > 0)
? $info->items
: \App\Post::where('server', $origin)
->where('node', $node)
->count()
);
$this->rpc('MovimUtils.setTitle',
$this->__('page.communities') .
' • ' .
$info->name ?? $info->node
);
}
return $view->draw('_communitydata');
}

2
app/widgets/Post/Post.php

@ -108,6 +108,7 @@ class Post extends Base
$this->rpc('MovimTpl.fill', '#post_widget.'.cleanupId($p->nodeid), $html);
$this->rpc('MovimUtils.enhanceArticlesContent');
$this->rpc('MovimUtils.setTitle', $this->__('page.post') . ' • ' . $p->title);
// If the post is a reply but we don't have the original
if ($p->isReply() && !$p->getReply()) {
@ -119,7 +120,6 @@ class Post extends Base
->request();
}
} else {
$this->rpc('MovimTpl.fill', '#post_widget', $this->prepareNotFound());
}
}

36
app/widgets/Post/_post.tpl

@ -220,22 +220,8 @@
{$c->preparePostLinks($post)}
{/autoescape}
{if="$post->pictures && !$post->isBrief() && !$post->isShort()"}
<ul class="list flex middle">
{loop="$post->pictures"}
<li class="block pic">
<span class="primary icon gray">
<i class="material-icons">image</i>
</span>
<a href="{$value->href}" class="alternate" target="_blank">
<img type="{$value->type}" src="{$value->href}"/>
</a>
</li>
{/loop}
</ul>
{/if}
{if="$post->openlink && !$public"}
<ul class="list active thick">
<ul class="list thick">
<li>
<span class="primary icon gray">
<i class="material-icons">wifi_tethering</i>
@ -254,6 +240,26 @@
</ul>
{/if}
{if="$post->pictures()->count() > 0 && !$post->isBrief() && !$post->isShort()"}
<ul class="list">
<li class="subheader">
<div>
<p>
{$c->__('general.pictures')}
</p>
</div>
</li>
</ul>
<ul class="grid active">
{loop="$post->pictures"}
<li style="background-image: url('{$value->href|protectPicture}')"
onclick="Preview_ajaxShow('{$value->href}')">
<i class="material-icons">visibility</i>
</li>
{/loop}
</ul>
{/if}
{if="$public"}
<div id="comments">
{autoescape="off"}

2
app/widgets/Post/_post_links.tpl

@ -4,7 +4,7 @@
<li>
<span class="primary icon gray">
{if="$value->logo"}
<img src="{$value->logo}"/>
<img src="{$value->logo|protectPicture}"/>
{else}
<i class="material-icons">link</i>
{/if}

64
composer.lock

@ -1642,16 +1642,16 @@
},
{
"name": "nesbot/carbon",
"version": "2.36.0",
"version": "2.36.1",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "d0b65958d9942fd1b501fdb0800c67e8323aa08d"
"reference": "ee7378a36cc62952100e718bcc58be4c7210e55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/d0b65958d9942fd1b501fdb0800c67e8323aa08d",
"reference": "d0b65958d9942fd1b501fdb0800c67e8323aa08d",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ee7378a36cc62952100e718bcc58be4c7210e55f",
"reference": "ee7378a36cc62952100e718bcc58be4c7210e55f",
"shasum": ""
},
"require": {
@ -1727,7 +1727,7 @@
"type": "tidelift"
}
],
"time": "2020-06-25T20:20:01+00:00"
"time": "2020-07-04T12:29:56+00:00"
},
{
"name": "paragonie/random_compat",
@ -2319,16 +2319,16 @@
},
{
"name": "react/http",
"version": "v0.8.6",
"version": "v0.8.7",
"source": {
"type": "git",
"url": "https://github.com/reactphp/http.git",
"reference": "248202e57195d06a4375f6d2f5c5b9ff9da3ea9e"
"reference": "9aa446fd86745403a09c315c90d4e464fd84382b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/http/zipball/248202e57195d06a4375f6d2f5c5b9ff9da3ea9e",
"reference": "248202e57195d06a4375f6d2f5c5b9ff9da3ea9e",
"url": "https://api.github.com/repos/reactphp/http/zipball/9aa446fd86745403a09c315c90d4e464fd84382b",
"reference": "9aa446fd86745403a09c315c90d4e464fd84382b",
"shasum": ""
},
"require": {
@ -2342,7 +2342,7 @@
},
"require-dev": {
"clue/block-react": "^1.1",
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35"
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
},
"type": "library",
"autoload": {
@ -2363,7 +2363,7 @@
"server",
"streaming"
],
"time": "2020-01-12T13:15:06+00:00"
"time": "2020-07-05T11:32:28+00:00"
},
{
"name": "react/promise",
@ -2988,16 +2988,16 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.1.2",
"version": "v2.1.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337"
"reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337",
"reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5e20b83385a77593259c9f8beb2c43cd03b2ac14",
"reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14",
"shasum": ""
},
"require": {
@ -3007,6 +3007,10 @@
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
@ -3044,7 +3048,7 @@
"type": "tidelift"
}
],
"time": "2020-05-27T08:34:37+00:00"
"time": "2020-06-06T08:49:21+00:00"
},
{
"name": "symfony/filesystem",
@ -3588,16 +3592,16 @@
},
{
"name": "symfony/service-contracts",
"version": "v2.1.2",
"version": "v2.1.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b"
"reference": "58c7475e5457c5492c26cc740cc0ad7464be9442"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b",
"reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/58c7475e5457c5492c26cc740cc0ad7464be9442",
"reference": "58c7475e5457c5492c26cc740cc0ad7464be9442",
"shasum": ""
},
"require": {
@ -3611,6 +3615,10 @@
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
@ -3656,7 +3664,7 @@
"type": "tidelift"
}
],
"time": "2020-05-20T17:43:50+00:00"
"time": "2020-07-06T13:23:11+00:00"
},
{
"name": "symfony/translation",
@ -3752,16 +3760,16 @@
},
{
"name": "symfony/translation-contracts",
"version": "v2.1.2",
"version": "v2.1.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation-contracts.git",
"reference": "e5ca07c8f817f865f618aa072c2fe8e0e637340e"
"reference": "616a9773c853097607cf9dd6577d5b143ffdcd63"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/e5ca07c8f817f865f618aa072c2fe8e0e637340e",
"reference": "e5ca07c8f817f865f618aa072c2fe8e0e637340e",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/616a9773c853097607cf9dd6577d5b143ffdcd63",
"reference": "616a9773c853097607cf9dd6577d5b143ffdcd63",
"shasum": ""
},
"require": {
@ -3774,6 +3782,10 @@
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
@ -3819,7 +3831,7 @@
"type": "tidelift"
}
],
"time": "2020-05-20T17:43:50+00:00"
"time": "2020-07-06T13:23:11+00:00"
},
{
"name": "symfony/yaml",

3
public/scripts/movim_utils.js

@ -63,6 +63,9 @@ var MovimUtils = {
return json;
},
setTitle: function(title) {
document.title = title;
},
pushState: function(url) {
window.history.pushState(null, '', url);
},

Loading…
Cancel
Save