Browse Source

Ajout partage Shaarli : fix issue #34

Marien Fressinaud 13 năm trước cách đây
mục cha
commit
cd979d30e1

+ 3 - 0
app/controllers/configureController.php

@@ -132,6 +132,7 @@ class configureController extends ActionController {
 			$openArticle = Request::param ('mark_open_article', 'no');
 			$openSite = Request::param ('mark_open_site', 'no');
 			$openPage = Request::param ('mark_open_page', 'no');
+			$urlShaarli = Request::param ('shaarli', '');
 
 			$this->view->conf->_postsPerPage (intval ($nb));
 			$this->view->conf->_defaultView ($view);
@@ -144,6 +145,7 @@ class configureController extends ActionController {
 				'site' => $openSite,
 				'page' => $openPage,
 			));
+			$this->view->conf->_urlShaarli ($urlShaarli);
 
 			$values = array (
 				'posts_per_page' => $this->view->conf->postsPerPage (),
@@ -153,6 +155,7 @@ class configureController extends ActionController {
 				'old_entries' => $this->view->conf->oldEntries (),
 				'mail_login' => $this->view->conf->mailLogin (),
 				'mark_when' => $this->view->conf->markWhen (),
+				'url_shaarli' => $this->view->conf->urlShaarli (),
 			);
 
 			$confDAO = new RSSConfigurationDAO ();

+ 17 - 2
app/models/RSSConfiguration.php

@@ -9,6 +9,7 @@ class RSSConfiguration extends Model {
 	private $shortcuts = array ();
 	private $mail_login = '';
 	private $mark_when = array ();
+	private $url_shaarli = '';
 	
 	public function __construct () {
 		$confDAO = new RSSConfigurationDAO ();
@@ -20,6 +21,7 @@ class RSSConfiguration extends Model {
 		$this->_shortcuts ($confDAO->shortcuts);
 		$this->_mailLogin ($confDAO->mail_login);
 		$this->_markWhen ($confDAO->mark_when);
+		$this->_urlShaarli ($confDAO->url_shaarli);
 	}
 	
 	public function postsPerPage () {
@@ -55,6 +57,9 @@ class RSSConfiguration extends Model {
 	public function markWhenPage () {
 		return $this->mark_when['page'];
 	}
+	public function urlShaarli () {
+		return $this->url_shaarli;
+	}
 	
 	public function _postsPerPage ($value) {
 		if (is_int (intval ($value))) {
@@ -108,11 +113,17 @@ class RSSConfiguration extends Model {
 		$this->mark_when['site'] = $values['site'];
 		$this->mark_when['page'] = $values['page'];
 	}
+	public function _urlShaarli ($value) {
+		$this->url_shaarli = '';
+		if (filter_var ($value, FILTER_VALIDATE_URL)) {
+			$this->url_shaarli = $value;
+		}
+	}
 }
 
 class RSSConfigurationDAO extends Model_array {
-	public $posts_per_page = 10;
-	public $default_view = 'all';
+	public $posts_per_page = 20;
+	public $default_view = 'not_read';
 	public $display_posts = 'no';
 	public $sort_order = 'low_to_high';
 	public $old_entries = 3;
@@ -131,6 +142,7 @@ class RSSConfigurationDAO extends Model_array {
 		'site' => 'yes',
 		'page' => 'no'
 	);
+	public $url_shaarli = '';
 
 	public function __construct () {
 		parent::__construct (PUBLIC_PATH . '/data/Configuration.array.php');
@@ -159,6 +171,9 @@ class RSSConfigurationDAO extends Model_array {
 		if (isset ($this->array['mark_when'])) {
 			$this->mark_when = $this->array['mark_when'];
 		}
+		if (isset ($this->array['url_shaarli'])) {
+			$this->url_shaarli = $this->array['url_shaarli'];
+		}
 	}
 	
 	public function update ($values) {

+ 8 - 0
app/views/configure/display.phtml

@@ -87,6 +87,14 @@
 			</div>
 		</div>
 
+		<legend>Partage</legend>
+		<div class="form-group">
+			<label class="group-name" for="shaarli">Votre Shaarli</label>
+			<div class="group-controls">
+				<input type="text" id="shaarli" name="shaarli" value="<?php echo $this->conf->urlShaarli (); ?>" placeholder="Laissez vide pour désactiver"/>
+			</div>
+		</div>
+
 		<div class="form-group form-actions">
 			<div class="group-controls">
 				<button type="submit" class="btn btn-important">Valider</button>

+ 6 - 0
app/views/index/index.phtml

@@ -80,6 +80,12 @@ if (isset ($this->entryPaginator)) {
 							<li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li>
 
 							<li class="item"><a href="mailto:?subject=<?php echo $item->title (); ?>&amp;body=J'ai trouvé cet article intéressant, tu peux le lire à cette adresse : <?php echo urlencode($item->link ()); ?>">Par mail</a></li>
+							<?php
+							$shaarli = $this->conf->urlShaarli ();
+							if ($shaarli) {
+							?>
+							<li class="item"><a target="_blank" href="<?php echo $shaarli . '?post=' . urlencode($item->link ()) . '&amp;title=' . urlencode ($item->title ()) . '&amp;source=bookmarklet'; ?>">Shaarli</a></li>
+							<?php } ?>
 						</ul>
 					</div>
 				</li>

+ 4 - 23
public/install.php

@@ -91,32 +91,13 @@ function saveStep2 () {
 
 		$file_data = PUBLIC_PATH . '/data/Configuration.array.php';
 
-		$conf = array (
-			'posts_per_page' => 20,
-			'default_view' => 'not_read',
-			'display_posts' => 'no',
-			'sort_order' => 'low_to_high',
-			'old_entries' => $_SESSION['old_entries'],
-			'mail_login' => $_SESSION['mail_login'],
-			'shortcuts' => array (
-				'mark_read' => 'r',
-				'mark_favorite' => 'f',
-				'go_website' => 'space',
-				'next_entry' => 'j',
-				'prev_entry' => 'k',
-				'next_page' => 'right',
-				'prev_page' => 'left',
-			),
-			'mark_when' => array (
-				'article' => 'yes',
-				'site' => 'yes',
-				'page' => 'no',
-			),
-		);
 		$f = fopen ($file_data, 'w');
 		writeLine ($f, '<?php');
 		writeLine ($f, 'return array (');
-		writeArray ($f, $conf);
+		writeArray ($f, array (
+			'old_entries' => $_SESSION['old_entries'],
+			'mail_login' => $_SESSION['mail_login']
+		));
 		writeLine ($f, ');');
 		fclose ($f);