Skip to content

Commit

Permalink
Merge branch 'proposals/version-1.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cdevroe committed Mar 25, 2019
2 parents fc7f59a + 4d3ae0a commit 98d5e39
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 96 deletions.
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
| version.point.release
|
*/
$config['unmark_version'] = '1.8.1';
$config['unmark_version'] = '1.9.0';

/*
|--------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

// Single Mark Actions
$route['marks?/add(.*?)'] = 'marks/add$1';
$route['marks?/add_by_url(.*?)'] = 'marks/add_by_url$1';
$route['mark/archive(.*?)'] = 'marks/archive$1';
$route['marks?/archive/old.*?'] = 'marks/archive/old';
$route['mark/check(.*?)'] = 'marks/check';
Expand Down
71 changes: 57 additions & 14 deletions application/controllers/Marks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public function __construct()
$this->load->model('users_to_marks_model', 'user_marks');
}

public function add_by_url()
{
// Figure view
$this->figureView('marks/add_by_url');
}

/*
- Add a mark
- URLS
Expand All @@ -24,13 +30,48 @@ public function __construct()
*/
public function add()
{
$redirect = null;
$view = null;
$url = (isset($this->db_clean->url)) ? $this->db_clean->url : null;
$title = (isset($this->db_clean->title)) ? $this->db_clean->title : null;
$options = array('url' => $url, 'title' => $title);
$redirect = null;
$view = null;
$add_from_url = ($this->input->post('add_from_url') !== null ) ? true : false;

if ( $add_from_url ) : // URL submitted by form within app
$url = $this->input->post('url');
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) { // Adds HTTP if needed
$url = "http://" . $url;
}
$title = '';
$dom = new DOMDocument();
libxml_use_internal_errors(true);
if (!$dom->loadHTMLFile($url, LIBXML_NOWARNING)) {
foreach (libxml_get_errors() as $error) {
// handle errors here
echo '<p>There was an error adding the mark.</p>';
if ( $error->code == 1549 ) {
echo '<p>Most likely the URL is invalid or the web site isn\'t currently available.</p>';
}
//print_r($error);

}
libxml_clear_errors();
exit;

} else {
$list = $dom->getElementsByTagName("title");
if ($list->length > 0) {
$title = $list->item(0)->textContent;
}
}

if ( strlen($title) == 0 ) :
$title = "Unknown Page Title";
endif;

else : // URL submitted via bookmarklet, API, or mobile app
$url = (isset($this->db_clean->url)) ? $this->db_clean->url : null;
$title = (isset($this->db_clean->title)) ? $this->db_clean->title : null;
endif;

//print_r( $_GET );
$options = array('url' => $url, 'title' => $title);

if ( empty($url) ) { // May be from an app via "share"
if ( isset($this->db_clean->notes) && ! empty($this->db_clean->notes) ) {
Expand All @@ -47,13 +88,6 @@ public function add()
}
}

// print_r($url);
// print_r($title);
// exit;

//print_r( $_SERVER['REQUEST_URI'] );
//exit;

// If label id was passed, use it.
if (isset($this->clean->label_id) && is_numeric($this->clean->label_id)) {
$options['label_id'] = $this->clean->label_id;
Expand All @@ -76,7 +110,11 @@ public function add()
}
else {
$this->data['mark'] = $user_mark;
$redirect = '/mark/info/' . $user_mark->mark_id . '?bookmarklet=true';
if ( $add_from_url ) {
$redirect = '/mark/info/' . $user_mark->mark_id . '?bookmarklet=false';
} else {
$redirect = '/mark/info/' . $user_mark->mark_id . '?bookmarklet=true';
}
}

// Figure what to do here (api, redirect or generate view)
Expand Down Expand Up @@ -573,6 +611,11 @@ public function info($mark_id=0)
$this->data['no_header'] = true;
$this->data['no_footer'] = true;

// print_r($_GET['bookmarklet']);
// exit;

$this->data['bookmarklet'] = (isset($_GET['bookmarklet'])) ? $_GET['bookmarklet'] : true;

// Figure view
$this->figureView('marks/info');
}
Expand Down
12 changes: 12 additions & 0 deletions application/views/layouts/topbar/searchform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<a class="search-button" href="#">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M18,8a6,6,0,1,0,6,6A6,6,0,0,0,18,8Zm0,10a4,4,0,1,1,4-4A4,4,0,0,1,18,18Z"/><rect x="10.54" y="16.46" width="2" height="8" transform="translate(17.85 -2.16) rotate(45)"/></svg>
</a>
<a class="add-mark-button" href="#">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><polygon points="24,15 17,15 17,8 15,8 15,15 8,15 8,17 15,17 15,24 17,24 17,17 24,17 "/></svg>
</a>
</section>
<section class="search-bar">
<i><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M18,8a6,6,0,1,0,6,6A6,6,0,0,0,18,8Zm0,10a4,4,0,1,1,4-4A4,4,0,0,1,18,18Z"/><rect x="10.54" y="16.46" width="2" height="8" transform="translate(17.85 -2.16) rotate(45)"/></svg></i>
Expand All @@ -11,3 +14,12 @@
</form>
<a class="close-button" href="#"></a>
</section>
<section class="add-mark-bar">
<i><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><polygon points="22,26 16,22 10,26 10,6 22,6 "/></svg></i>
<form method="post" action="/marks/add" id="add-mark-form">
<input type="hidden" name="add_from_url" value="1">
<input type="text" name="url" id="add-mark-input" placeholder="<?php echo unmark_phrase('Enter URL...') ?>" autocapitalize="off">
<button type="submit"><?php echo unmark_phrase('Add<span> Mark</span>') ?></button><!-- **Add to phrases** -->
</form>
<a class="close-button" href="#"></a>
</section>
31 changes: 31 additions & 0 deletions application/views/marks/add_by_url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
$url = '';
if ( $_POST ) :
$time_start = microtime(true);


$url = $_POST['url'];
echo '<p><strong>URL:</strong>' . $url . '</p>';

$title = '';
$dom = new DOMDocument();
libxml_use_internal_errors(true);
if ($dom->loadHTMLFile($_POST['url'])) {
$list = $dom->getElementsByTagName("title");
if ($list->length > 0) {
$title = $list->item(0)->textContent;
}
}
$time_end = microtime(true);
if ( strlen($title) > 0 ) : echo '<p><strong>Title:</strong> ' . $title . '</p>'; endif;
$execution_time = ($time_end - $time_start);
echo '<p><b>Total Execution Time:</b> '.$execution_time.' seconds</p>';

endif; ?>

<form method="post" action="/marks/add">
<input type="hidden" name="add_from_url" value="1">
<input type="text" name="url" value="<?=$url;?>" placeholder="http://">
<input type="submit" value="Get">
</form>

8 changes: 7 additions & 1 deletion application/views/marks/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@
</div>

<div class="mark-added-actions">
<?php if ( $bookmarklet == 'true' ) { ?>
<div class="delete-button">
<button class="delete" data-action="delete_mark" data-view="bookmarklet" data-id="<?php print $mark->mark_id; ?>"><?php echo unmark_phrase('Delete Link'); ?></button>
</div>
<?php } ?>
<div class="update-button">
<button data-action="close_window"><?php echo unmark_phrase('Update &amp; Close'); ?></button>
<?php if ( $bookmarklet == 'true' ) { ?>
<button data-action="close_window"><?php echo unmark_phrase('Update &amp; Close'); ?></button>
<?php } else { ?>
<button><a href="/"><?php echo unmark_phrase('Update &amp; Return'); ?></a></button>
<?php } ?>
</div>
</div>

Expand Down
57 changes: 0 additions & 57 deletions application/views/singletons/changelog.php

This file was deleted.

24 changes: 21 additions & 3 deletions assets/css/partials/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
padding: 16px 20px 16px 30px;
height: 80px;
}
.search-bar {
.search-bar, .add-mark-bar {
height: 100%;
width: 100%;
padding: 10px 100px 10px 18px;
Expand Down Expand Up @@ -190,6 +190,23 @@
}
}
}
.add-mark-bar {
@include sm {
padding: 16px 170px 16px 60px;
}
button {
width: 42px;
@include sm {
width: 86px;
}
span {
display: none;
@include sm {
display: inline;
}
}
}
}
.buttons {
display: block;
width: auto;
Expand All @@ -204,15 +221,16 @@
right: 20px;
}
> a {
display: block;
display: inline-block;
width: 28px;
height: 28px;
border-radius: 50%;
margin-left: 10px;
margin-left: 4px;
@include sm {
border: 1px solid darken(desaturate($color_gray, 10%), 18%);
width: 32px;
height: 32px;
margin-left: 10px;
}
svg {
fill: darken(desaturate($color_gray, 10%), 18%);
Expand Down
2 changes: 1 addition & 1 deletion assets/css/partials/_stream.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
.mark-link a {
text-decoration: none;
color: darken($color_light, 15%);
display: inline;
display: inline-block;
vertical-align: bottom;
@include unmark-truncate(65%);
}
Expand Down
4 changes: 1 addition & 3 deletions assets/js/templates/JS-Templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ <h4 class="prev-coll">Preview <i class="icon-up"></i></h4>
<h4 class="action" data-action="marks_editMarkInfo">Notes (click to edit) <i class="icon-edit"></i></h4>
<section id="notes-{{mark_id}}" data-id="{{mark_id}}" class="sidebar-info-notes hideoutline">{{{notes}}}</section>
</div>
{{#archived_on}}
<button data-id="{{mark_id}}" data-view="sidebar" data-action="delete_mark">Delete Link</button>
{{/archived_on}}
<button data-id="{{mark_id}}" data-view="sidebar" data-action="delete_mark">Delete Link</button>
</main>

<!-- Main Mark Listing Template -->
Expand Down
2 changes: 1 addition & 1 deletion assets/js/templates/unmark-templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 98d5e39

Please sign in to comment.