Skip to content

Commit

Permalink
Merge pull request #256 from cdevroe/proposals/version-2.0
Browse files Browse the repository at this point in the history
Proposals/version 2.0
  • Loading branch information
cdevroe committed May 21, 2020
2 parents 598ea7a + 2ef0e3b commit 8ea4f28
Show file tree
Hide file tree
Showing 57 changed files with 2,556 additions and 1,772 deletions.
35 changes: 30 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = function(grunt) {

var js_file_config = {
'assets/js/production/unmark.plugins.js': [
'assets/js/plugins/hogan.js',
'assets/js/plugins/hogan.js',
'assets/js/plugins/selectize.min.js',
'assets/js/plugins/jquery.pjax.js',
'assets/js/plugins/fitvids.js'
],
Expand Down Expand Up @@ -83,6 +84,11 @@ module.exports = function(grunt) {
}
},
copy: {
custom: {
files: [
{expand: true, flatten: false, cwd: '../unmark-internal/custom/', src: ['**'], dest: '../unmark/custom/'}
]
},
release: {
files: [
{expand: true, flatten: false, src: ['application/**', '!application/config/database.php'], dest: 'release/unmark/'},
Expand All @@ -105,6 +111,11 @@ module.exports = function(grunt) {
]
}
},
clean: {
custom: ['custom/*'],
releasePrepare: ['release/*'],
releaseFinal: ['release/*', '!release/unmark.zip']
},
compress: {
dist: {
options: {
Expand Down Expand Up @@ -139,11 +150,25 @@ module.exports = function(grunt) {
// Load the Tasks
require('load-grunt-tasks')(grunt);

grunt.registerTask('default', [ 'sass:prod', 'uglify:prod' ]); // Default Build for OS Project
// --------------- TASKS

// Default task:
// Compiles CSS, compresses JavaScript.
grunt.registerTask('default', [ 'sass:prod', 'uglify:prod' ]);

// Release task:
// Cleans release directory, compiles CSS and compresses JavaScript. Copies all files to /release/unmark, compresses a zip, deletes /release/unmark
grunt.registerTask('release', [ 'clean:releasePrepare', 'sass:prod', 'uglify:prod', 'copy:release', 'compress:dist', 'clean:releaseFinal' ]);

grunt.registerTask('release', [ 'sass:prod', 'uglify:prod', 'copy:release' ]); // Build for OS release
// Dev build task:
// Does not compress files, easier to debug
grunt.registerTask('dev', [ 'sass:prod', 'concat:dev', 'concat:custom' ]);

// Production build task:
// Deletes contents of custom folder, copies new custom files, compresses everything (used primarily for unmark.it)
grunt.registerTask('production', [ 'makeCustom', 'sass:prod', 'uglify:prod', 'uglify:custom' ]);

grunt.registerTask('dev', [ 'sass:prod', 'concat:dev', 'concat:custom' ]); // Dev build
grunt.registerTask('production', [ 'sass:prod', 'uglify:prod', 'uglify:custom' ]); // Default Production Build
// Utility tasks that deletes/copies /custom/
grunt.registerTask( 'makeCustom', [ 'clean:custom', 'copy:custom' ] ); // Copies ../unmark-internal/custom to ../unmark/custom

};
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.9.2';
$config['unmark_version'] = '2020.1';

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

// Tags
$route['tag/add(.*?)'] = 'tags/add';
$route['tags/getAutocomplete(.*?)'] = 'tags/getAutocomplete';
$route['tags?(.*?)'] = 'tags/index$1';

// Registration
Expand Down
117 changes: 71 additions & 46 deletions application/controllers/Marks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ 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
- Add a mark
- URLS
/mark/add
/mark/add/?url=URL
/api/mark/add
// Query variables
Expand All @@ -34,38 +29,52 @@ public function add()
$view = null;
$add_from_url = ($this->input->post('add_from_url') !== null ) ? true : false;

if ( isset($_GET['url']) && !isset($_GET['title']) ) {
$add_from_url = true;
}

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();
$url = (isset($_GET['url'])) ? $this->input->get('url') : $this->input->post('url');

if ( !$url || $url == '' ) :
echo '<a href="/">BACK</a> - Please supply an URL.';
exit;

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

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

if (!preg_match("~^(?:f|ht)tps?://~i", $url)) : // Adds HTTP if needed
$url = "http://" . $url;
endif;

$title = (isset($_GET['title'])) ? $this->input->get('title') : ''; // If title is supplied, use that

if ( $title == '' ) : // If title is empty, go get it
$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><a href="/">BACK</a> 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>';
endif;
endforeach;
libxml_clear_errors();
exit;

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

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

endif; // end if empty title

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;
Expand Down Expand Up @@ -253,19 +262,33 @@ public function edit($mark_id=0)
$options['notes'] = $this->db_clean->notes;

// Check for hashmarks to tags
$tags = getTagsFromHash($options['notes']);
//Removed in 2.0 $tags = getTagsFromHash($options['notes']);
}

// If tags are present, set them
if (isset($this->db_clean->tags)) {
if ( $this->db_clean->tags == 'unmark:removeAllTags' ) { // Remove all tags by sending empty array
$tags = array();
parent::removeTags($mark_id);
} else {
$tags = explode( ',', $this->db_clean->tags );
}
}

// If tags are present, handle differently
// Need to add to tags table first
// Then create association
// If notes are present set them
if (isset($tags)) {
if (isset($tags) && count($tags) > 0) {
parent::addTags($tags, $mark_id);
}

// Update users_to_marks record
$mark = $this->user_marks->update("users_to_marks.user_id = '" . $this->user_id . "' AND users_to_marks.users_to_mark_id = '" . $mark_id . "'", $options);
if ( isset($options) && count($options) > 0) {
// Update users_to_marks record
$mark = $this->user_marks->update("users_to_marks.user_id = '" . $this->user_id . "' AND users_to_marks.users_to_mark_id = '" . $mark_id . "'", $options);
} else {
$mark = $this->user_marks->readComplete($mark_id);
}

// Check if it was updated
if ($mark === false) {
Expand Down Expand Up @@ -313,6 +336,8 @@ public function edit($mark_id=0)

public function get($what='stats')
{
log_message( 'DEBUG', 'Running get method for ' . $what );

parent::redirectIfWebView();
$method = 'get' . ucwords($what);

Expand Down Expand Up @@ -384,13 +409,14 @@ private function getStats()

}

// Get the 10 most used tags for a user
// Get the 10 most used and most recent tags for a user
private function getTags()
{
$this->data['tags'] = array();
$this->load->model('user_marks_to_tags_model', 'user_tags');
$this->data['tags']['popular'] = $this->user_tags->getPopular($this->user_id);
$this->data['tags']['recent'] = $this->user_tags->getMostRecent($this->user_id);
$this->data['tags'] = array();

$this->data['tags']['popular'] = $this->user_tags->getPopular($this->user_id);
$this->data['tags']['recent'] = $this->user_tags->getMostRecent($this->user_id);
}

// The index of the marks page
Expand Down Expand Up @@ -575,7 +601,7 @@ public function index()
// Get stats, labels and tags
// else skip this section and just return the marks
if (parent::isWebView() === true) {
self::getStats();
//self::getStats();
self::getLabels();
self::getTags();
}
Expand Down Expand Up @@ -611,11 +637,10 @@ 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;

self::getTags();

// Figure view
$this->figureView('marks/info');
}
Expand Down
25 changes: 23 additions & 2 deletions application/controllers/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function index($page=1)
// Read the complete user marks records
$tags = $this->tags->read($where, $this->limit, $page);

// If no labels, return error
// Else return labels
// If no tags, return error
// Else return tags
if ($tags === false) {
$this->data['errors'] = formatErrors(60);
}
Expand All @@ -39,6 +39,27 @@ public function index($page=1)
$this->figureView();
}

// Used to get a list of popular and recent tags
// Primarily used for tag autocompletion.
public function getAutocomplete()
{

$this->load->model('user_marks_to_tags_model', 'user_tags');
$this->data['tags'] = array();
$tags_popular = array();
$tags_recent = array();

$tags_popular = $this->user_tags->getPopular($this->user_id);
$tags_recent = $this->user_tags->getMostRecent($this->user_id);

if (is_array($tags_recent)) {
$this->data['tags'] = array_merge( $tags_popular, $tags_recent);
}

// Figure if web or API view
$this->figureView();
}

public function add()
{

Expand Down
8 changes: 8 additions & 0 deletions application/core/Plain_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ protected function addMark($data=array())

}

protected function removeTags($mark_id)
{
$this->load->model('tags_model', 'tag');
$this->load->model('user_marks_to_tags_model', 'mark_to_tag');

$delete = $this->mark_to_tag->delete("users_to_mark_id = '" . $mark_id . "' AND user_id = '" . $this->user_id . "'");
}

protected function addTags($tags, $mark_id)
{
if (! empty($tags) && is_array($tags)) {
Expand Down
4 changes: 2 additions & 2 deletions application/views/email/forgot-password.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unmark // Reset Password</title>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Montserrat:400);
@import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700);
/* Client-specific Styles */
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
Expand Down Expand Up @@ -323,4 +323,4 @@
<!-- End of preheader -->
</div>
</body></html>
</body></html>
4 changes: 2 additions & 2 deletions application/views/email/update-password.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unmark // Password Updated</title>
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Montserrat:400);
@import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700);
/* Client-specific Styles */
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
Expand Down Expand Up @@ -340,4 +340,4 @@
<!-- End of preheader -->
</div>
</body></html>
</body></html>
2 changes: 1 addition & 1 deletion application/views/errors/html/error_404.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Sorry, we can't find this page</title>
<link href='http://fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/assets/css/unmark.css">
<link rel="icon" type="image/ico" href="favicon.ico">
</head>
Expand Down
2 changes: 1 addition & 1 deletion application/views/errors/html/error_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Eek, something is wrong</title>
<link href='http://fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/assets/css/unmark.css">
<link rel="icon" type="image/ico" href="/favicon.ico">
</head>
Expand Down
2 changes: 1 addition & 1 deletion application/views/errors/html/error_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Eek, something is wrong</title>
<link href='http://fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/assets/css/unmark.css">
<link rel="icon" type="image/ico" href="/favicon.ico">
</head>
Expand Down
2 changes: 1 addition & 1 deletion application/views/import/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<title><?php echo unmark_phrase('Unmark : Importer'); ?></title>
<link href='//fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/assets/css/unmark.css" />
<link rel="icon" type="image/ico" href="/favicon.ico" />
</head>
Expand Down

0 comments on commit 8ea4f28

Please sign in to comment.