diff --git a/application/config/config.php b/application/config/config.php index b43cecfe..68077fd2 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -11,7 +11,7 @@ | version.point.release | */ -$config['unmark_version'] = '1.8.1'; +$config['unmark_version'] = '1.9.0'; /* |-------------------------------------------------------------------------- diff --git a/application/config/routes.php b/application/config/routes.php index 9c80e98e..e607d1cd 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -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'; diff --git a/application/controllers/Marks.php b/application/controllers/Marks.php index e513459e..09102ed4 100644 --- a/application/controllers/Marks.php +++ b/application/controllers/Marks.php @@ -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 @@ -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 '

There was an error adding the mark.

'; + if ( $error->code == 1549 ) { + echo '

Most likely the URL is invalid or the web site isn\'t currently available.

'; + } + //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) ) { @@ -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; @@ -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) @@ -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'); } diff --git a/application/views/layouts/topbar/searchform.php b/application/views/layouts/topbar/searchform.php index 2b79229e..35c1ba80 100644 --- a/application/views/layouts/topbar/searchform.php +++ b/application/views/layouts/topbar/searchform.php @@ -2,6 +2,9 @@ + + + +
+ +
+ + + +
+ +
diff --git a/application/views/marks/add_by_url.php b/application/views/marks/add_by_url.php new file mode 100644 index 00000000..1b0dea9e --- /dev/null +++ b/application/views/marks/add_by_url.php @@ -0,0 +1,31 @@ +URL:' . $url . '

'; + + $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 '

Title: ' . $title . '

'; endif; + $execution_time = ($time_end - $time_start); + echo '

Total Execution Time: '.$execution_time.' seconds

'; + +endif; ?> + +
+ + + +
+ diff --git a/application/views/marks/info.php b/application/views/marks/info.php index da1b8e1d..2a9cbab4 100644 --- a/application/views/marks/info.php +++ b/application/views/marks/info.php @@ -47,11 +47,17 @@
+
+
- + + + + +
diff --git a/application/views/singletons/changelog.php b/application/views/singletons/changelog.php deleted file mode 100644 index 40514d95..00000000 --- a/application/views/singletons/changelog.php +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - <?php echo unmark_phrase('Unmark : Version Changelog'); ?> - - - - - - - - - -

Changelog

- -

This changelog relates to the hosted version of Unmark at unmark.it

- -

Wednesday, February 27, 2019

-Version: 1.8.1 - - -

Saturday, February 23, 2019

-Version: 1.8.095 - - - - - - - - - diff --git a/assets/css/partials/_main.scss b/assets/css/partials/_main.scss index a081be3d..562ee83f 100644 --- a/assets/css/partials/_main.scss +++ b/assets/css/partials/_main.scss @@ -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; @@ -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; @@ -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%); diff --git a/assets/css/partials/_stream.scss b/assets/css/partials/_stream.scss index 28386cd2..fc0ccd29 100644 --- a/assets/css/partials/_stream.scss +++ b/assets/css/partials/_stream.scss @@ -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%); } diff --git a/assets/js/templates/JS-Templates.html b/assets/js/templates/JS-Templates.html index a81e0d9b..1970e6b3 100644 --- a/assets/js/templates/JS-Templates.html +++ b/assets/js/templates/JS-Templates.html @@ -25,9 +25,7 @@

Preview

Notes (click to edit)

- {{#archived_on}} - - {{/archived_on}} + diff --git a/assets/js/templates/unmark-templates.js b/assets/js/templates/unmark-templates.js index 3b2d9e1d..5640f403 100644 --- a/assets/js/templates/unmark-templates.js +++ b/assets/js/templates/unmark-templates.js @@ -2,7 +2,7 @@ if (unmark === undefined) { var unmark = {}; } unmark.template = unmark.template || {}; -unmark.template.sidebar = '

URL

{{#archived_on}}{{/archived_on}}
'; +unmark.template.sidebar = '

URL

'; //unmark.template.marks = '

{{title}}

{{nice_time}}{{prettyurl}}
'; unmark.template.marks = '

{{title}}

{{nice_time}} {{prettyurl}}
{{#archived_on}} {{/archived_on}} {{^archived_on}} {{/archived_on}}
'; diff --git a/assets/js/unmark.actions.js b/assets/js/unmark.actions.js index 3115f632..52ecd7fd 100644 --- a/assets/js/unmark.actions.js +++ b/assets/js/unmark.actions.js @@ -67,31 +67,42 @@ unmark.interact_nav = function (e, elem_ckd) { e.preventDefault(); - var panel_to_show = (elem_ckd.data('panel')) ? elem_ckd.data('panel') : '', // kept in data attribute - panel_name = (panel_to_show !== '') ? panel_to_show.replace(/^#/, '') : '', // just removes # - is_label_menu = (panel_name.indexOf('label') !== -1) ? true : false, // checks name of panel to see if this is label menu - is_label_filter = (elem_ckd.attr('href').indexOf('label') !== -1) ? true : false, // checks href to see if this is label filter - is_tag_menu = (panel_name.indexOf('tags') !== -1) ? true : false, // checks name of panel to see if it is tags menu - is_tag_filter = (elem_ckd.attr('href').indexOf('tag') !== -1) ? true : false; // checks href to see if this is an actual hashtag + var panel_to_show = (elem_ckd.data('panel')) ? elem_ckd.data('panel') : '', // kept in data attribute + panel_name = (panel_to_show !== '') ? panel_to_show.replace(/^#/, '') : '', // just removes # + is_label_menu = (panel_name.indexOf('label') !== -1) ? true : false, // checks name of panel to see if this is label menu + is_label_filter = (elem_ckd.attr('href').indexOf('label') !== -1) ? true : false, // checks href to see if this is label filter + is_tag_menu = (panel_name.indexOf('tags') !== -1) ? true : false, // checks name of panel to see if it is tags menu + is_tag_filter = (elem_ckd.attr('href').indexOf('tag') !== -1) ? true : false, // checks href to see if this is an actual hashtag + is_archive_menu = (panel_name.indexOf('archive') !== -1) ? true : false, // checks panel name to see if this is the archive menu + hide_mobile_sub_menu = false; // on mobile, hide the submenu, default false // This means one of the labels was clicked. if ( is_label_menu || is_label_filter ) { - panel_name = 'panel-label'; - panel_to_show = '#'+panel_name; - + panel_name = 'panel-label'; + panel_to_show = '#'+panel_name; + hide_mobile_sub_menu = true; // hiding submenu } // For the tag menu, or actual hashtags if ( is_tag_menu || is_tag_filter ) { - panel_name = 'panel-tags'; - panel_to_show = '#'+panel_name; + panel_name = 'panel-tags'; + panel_to_show = '#'+panel_name; + if ( !is_tag_menu && is_tag_filter ) { // tag filter was clicked + hide_mobile_sub_menu = true; + } else if ( is_tag_menu && !is_tag_filter ) { // tag menu was clicked, but _Not_ tag filter + hide_mobile_sub_menu = false; + } + } + + if ( is_archive_menu ) { + hide_mobile_sub_menu = true; } // Add / Remove Class for current navigation $('.menu-item').removeClass('active-menu'); $('.navigation-content').find("[data-menu='" + panel_name + "']").addClass('active-menu'); - // For all panels run pjax manually. + // For all panels (except settings) run pjax manually. if ( panel_to_show !== "#panel-settings" ) { $.pjax({ url: elem_ckd.attr('href'), container: '.main-content', timeout:6000 }); } @@ -104,7 +115,7 @@ // clicked on any main navigation item other than hashtags // click on an actual hashtag // click on an actual label - if (Modernizr.mq('only screen and (max-width: 480px)') && panel_to_show !== '#panel-settings' && (is_label_menu || is_tag_filter || is_label_filter)) { + if (Modernizr.mq('only screen and (max-width: 480px)') && hide_mobile_sub_menu ) { unmark.mobile_nav(true); } return false; diff --git a/assets/js/unmark.init.js b/assets/js/unmark.init.js index 7ec9a5dd..16005177 100644 --- a/assets/js/unmark.init.js +++ b/assets/js/unmark.init.js @@ -203,6 +203,15 @@ $(this).closest('.search-bar').fadeOut(300); return false; }); + // Show & Hide Add Mark Bar + $(document).on('click', '.marks-heading-bar .add-mark-button', function(e) { + e.preventDefault(); + $(this).closest('.marks-heading-bar').find('.add-mark-bar').fadeIn(300); + }); + $(document).on('click', '.marks-heading-bar .add-mark-bar .close-button', function(e) { + e.preventDefault(); + $(this).closest('.add-mark-bar').fadeOut(300); + }); }; diff --git a/package.json b/package.json index 83960d46..899113d7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unmark", "url": "http://unmark.it", - "version": "1.8.0", + "version": "1.9.0", "description": "The open source to-do application for bookmarks.", "author": "https://unmark.it/", "main": "Gruntfile.js", diff --git a/readme.md b/readme.md index 85a306ec..f6e4b100 100644 --- a/readme.md +++ b/readme.md @@ -18,7 +18,7 @@ Running Unmark is only recommended for intermediate users. This doesn't mean if - Apache 2.x - PHP 5.6 or greater -- mySQL 5.5 or greater +- mySQL 5.7 or greater **Experimental: Docker** If you're going to use Docker we've included the appropriate Docker Compose, Dockerfile, and PHP.ini files to do so. This is still in its experimental phase though. We will update this readme with better instructions.