mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-01 17:38:38 +00:00
Share entry with a public URL
This commit is contained in:
parent
1bee9e0760
commit
f3d0cb9106
5 changed files with 116 additions and 1 deletions
|
@ -60,6 +60,7 @@ security:
|
||||||
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
|
- { path: ^/share, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/settings, roles: ROLE_SUPER_ADMIN }
|
- { path: ^/settings, roles: ROLE_SUPER_ADMIN }
|
||||||
- { path: ^/annotations, roles: ROLE_USER }
|
- { path: ^/annotations, roles: ROLE_USER }
|
||||||
- { path: ^/, roles: ROLE_USER }
|
- { path: ^/, roles: ROLE_USER }
|
||||||
|
|
|
@ -291,6 +291,8 @@ class EntryController extends Controller
|
||||||
{
|
{
|
||||||
$this->checkUserAction($entry);
|
$this->checkUserAction($entry);
|
||||||
|
|
||||||
|
$this->generateEntryUuid($entry);
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'WallabagCoreBundle:Entry:entry.html.twig',
|
'WallabagCoreBundle:Entry:entry.html.twig',
|
||||||
['entry' => $entry]
|
['entry' => $entry]
|
||||||
|
@ -449,5 +451,34 @@ class EntryController extends Controller
|
||||||
private function checkIfEntryAlreadyExists(Entry $entry)
|
private function checkIfEntryAlreadyExists(Entry $entry)
|
||||||
{
|
{
|
||||||
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Share entry content.
|
||||||
|
*
|
||||||
|
* @param Entry $entry
|
||||||
|
*
|
||||||
|
* @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share")
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function shareEntry(Entry $entry)
|
||||||
|
{
|
||||||
|
return $this->render(
|
||||||
|
'@WallabagCore/themes/share.html.twig',
|
||||||
|
array('entry' => $entry)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Entry $entry
|
||||||
|
*/
|
||||||
|
private function generateEntryUuid(Entry $entry)
|
||||||
|
{
|
||||||
|
$entry->generateUuid();
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$em->persist($entry);
|
||||||
|
$em->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,15 @@ class Entry
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="uuid", type="text", nullable=true)
|
||||||
|
*
|
||||||
|
* @Groups({"entries_for_user", "export_all"})
|
||||||
|
*/
|
||||||
|
private $uuid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
|
@ -427,6 +436,8 @@ class Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updatedAt = new \DateTime();
|
$this->updatedAt = new \DateTime();
|
||||||
|
|
||||||
|
$this->generateUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -595,4 +606,31 @@ class Entry
|
||||||
{
|
{
|
||||||
return $this->language;
|
return $this->language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getUuid()
|
||||||
|
{
|
||||||
|
return $this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $uuid
|
||||||
|
*
|
||||||
|
* @return Entry
|
||||||
|
*/
|
||||||
|
public function setUuid($uuid)
|
||||||
|
{
|
||||||
|
$this->uuid = $uuid;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateUuid()
|
||||||
|
{
|
||||||
|
if (empty($this->uuid) || is_null($this->uuid)) {
|
||||||
|
$this->uuid = uniqid();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,13 @@
|
||||||
</a>
|
</a>
|
||||||
<div class="collapsible-body">
|
<div class="collapsible-body">
|
||||||
<ul>
|
<ul>
|
||||||
|
{% if craue_setting('share_twitter') %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('share', {'uuid': entry.uuid }) }}" target="_blank" class="tool public" title="public">
|
||||||
|
<span>public</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% if craue_setting('share_twitter') %}
|
{% if craue_setting('share_twitter') %}
|
||||||
<li>
|
<li>
|
||||||
<a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="twitter">
|
<a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="twitter">
|
||||||
|
@ -149,7 +156,6 @@
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<li class="bold">
|
<li class="bold">
|
||||||
<a class="waves-effect collapsible-header">
|
<a class="waves-effect collapsible-header">
|
||||||
<i class="material-icons small">file_download</i>
|
<i class="material-icons small">file_download</i>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{{ entry.title | raw }}</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 10px;
|
||||||
|
font-family: 'Roboto',Verdana,Geneva,sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
header h1 {
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,
|
||||||
|
a:hover,
|
||||||
|
a:visited {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
article {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 600px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>{{ entry.title | raw }}</h1>
|
||||||
|
</header>
|
||||||
|
<article>
|
||||||
|
{{ entry.content | raw }}
|
||||||
|
</article>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue