Skip to content

Commit 8ea4f28

Browse files
authored
Merge pull request #256 from cdevroe/proposals/version-2.0
Proposals/version 2.0
2 parents 598ea7a + 2ef0e3b commit 8ea4f28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2556
-1772
lines changed

Gruntfile.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ module.exports = function(grunt) {
1818

1919
var js_file_config = {
2020
'assets/js/production/unmark.plugins.js': [
21-
'assets/js/plugins/hogan.js',
21+
'assets/js/plugins/hogan.js',
22+
'assets/js/plugins/selectize.min.js',
2223
'assets/js/plugins/jquery.pjax.js',
2324
'assets/js/plugins/fitvids.js'
2425
],
@@ -83,6 +84,11 @@ module.exports = function(grunt) {
8384
}
8485
},
8586
copy: {
87+
custom: {
88+
files: [
89+
{expand: true, flatten: false, cwd: '../unmark-internal/custom/', src: ['**'], dest: '../unmark/custom/'}
90+
]
91+
},
8692
release: {
8793
files: [
8894
{expand: true, flatten: false, src: ['application/**', '!application/config/database.php'], dest: 'release/unmark/'},
@@ -105,6 +111,11 @@ module.exports = function(grunt) {
105111
]
106112
}
107113
},
114+
clean: {
115+
custom: ['custom/*'],
116+
releasePrepare: ['release/*'],
117+
releaseFinal: ['release/*', '!release/unmark.zip']
118+
},
108119
compress: {
109120
dist: {
110121
options: {
@@ -139,11 +150,25 @@ module.exports = function(grunt) {
139150
// Load the Tasks
140151
require('load-grunt-tasks')(grunt);
141152

142-
grunt.registerTask('default', [ 'sass:prod', 'uglify:prod' ]); // Default Build for OS Project
153+
// --------------- TASKS
154+
155+
// Default task:
156+
// Compiles CSS, compresses JavaScript.
157+
grunt.registerTask('default', [ 'sass:prod', 'uglify:prod' ]);
158+
159+
// Release task:
160+
// Cleans release directory, compiles CSS and compresses JavaScript. Copies all files to /release/unmark, compresses a zip, deletes /release/unmark
161+
grunt.registerTask('release', [ 'clean:releasePrepare', 'sass:prod', 'uglify:prod', 'copy:release', 'compress:dist', 'clean:releaseFinal' ]);
143162

144-
grunt.registerTask('release', [ 'sass:prod', 'uglify:prod', 'copy:release' ]); // Build for OS release
163+
// Dev build task:
164+
// Does not compress files, easier to debug
165+
grunt.registerTask('dev', [ 'sass:prod', 'concat:dev', 'concat:custom' ]);
166+
167+
// Production build task:
168+
// Deletes contents of custom folder, copies new custom files, compresses everything (used primarily for unmark.it)
169+
grunt.registerTask('production', [ 'makeCustom', 'sass:prod', 'uglify:prod', 'uglify:custom' ]);
145170

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

149174
};

application/config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| version.point.release
1212
|
1313
*/
14-
$config['unmark_version'] = '1.9.2';
14+
$config['unmark_version'] = '2020.1';
1515

1616
/*
1717
|--------------------------------------------------------------------------

application/config/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979

8080
// Tags
8181
$route['tag/add(.*?)'] = 'tags/add';
82+
$route['tags/getAutocomplete(.*?)'] = 'tags/getAutocomplete';
8283
$route['tags?(.*?)'] = 'tags/index$1';
8384

8485
// Registration

application/controllers/Marks.php

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ public function __construct()
1111
$this->load->model('users_to_marks_model', 'user_marks');
1212
}
1313

14-
public function add_by_url()
15-
{
16-
// Figure view
17-
$this->figureView('marks/add_by_url');
18-
}
19-
2014
/*
21-
- Add a mark
15+
- Add a mark
2216
- URLS
2317
/mark/add
18+
/mark/add/?url=URL
2419
/api/mark/add
2520
2621
// Query variables
@@ -34,38 +29,52 @@ public function add()
3429
$view = null;
3530
$add_from_url = ($this->input->post('add_from_url') !== null ) ? true : false;
3631

32+
if ( isset($_GET['url']) && !isset($_GET['title']) ) {
33+
$add_from_url = true;
34+
}
35+
3736
if ( $add_from_url ) : // URL submitted by form within app
38-
$url = $this->input->post('url');
39-
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) { // Adds HTTP if needed
40-
$url = "http://" . $url;
41-
}
42-
$title = '';
43-
$dom = new DOMDocument();
44-
libxml_use_internal_errors(true);
45-
if (!$dom->loadHTMLFile($url, LIBXML_NOWARNING)) {
46-
foreach (libxml_get_errors() as $error) {
47-
// handle errors here
48-
echo '<p>There was an error adding the mark.</p>';
49-
if ( $error->code == 1549 ) {
50-
echo '<p>Most likely the URL is invalid or the web site isn\'t currently available.</p>';
51-
}
52-
//print_r($error);
5337

54-
}
55-
libxml_clear_errors();
38+
$url = (isset($_GET['url'])) ? $this->input->get('url') : $this->input->post('url');
39+
40+
if ( !$url || $url == '' ) :
41+
echo '<a href="/">BACK</a> - Please supply an URL.';
5642
exit;
57-
58-
} else {
59-
$list = $dom->getElementsByTagName("title");
60-
if ($list->length > 0) {
61-
$title = $list->item(0)->textContent;
62-
}
63-
}
64-
65-
if ( strlen($title) == 0 ) :
66-
$title = "Unknown Page Title";
6743
endif;
6844

45+
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) : // Adds HTTP if needed
46+
$url = "http://" . $url;
47+
endif;
48+
49+
$title = (isset($_GET['title'])) ? $this->input->get('title') : ''; // If title is supplied, use that
50+
51+
if ( $title == '' ) : // If title is empty, go get it
52+
$dom = new DOMDocument();
53+
libxml_use_internal_errors(true);
54+
if (!$dom->loadHTMLFile($url, LIBXML_NOWARNING)) :
55+
foreach (libxml_get_errors() as $error) :
56+
// handle errors here
57+
echo '<p><a href="/">BACK</a> There was an error adding the mark.</p>';
58+
if ( $error->code == 1549 ) :
59+
echo '<p>Most likely the URL is invalid or the web site isn\'t currently available.</p>';
60+
endif;
61+
endforeach;
62+
libxml_clear_errors();
63+
exit;
64+
65+
else :
66+
$list = $dom->getElementsByTagName("title");
67+
if ($list->length > 0) :
68+
$title = $list->item(0)->textContent;
69+
endif;
70+
endif;
71+
72+
if ( strlen($title) == 0 ) :
73+
$title = "Unknown Page Title";
74+
endif;
75+
76+
endif; // end if empty title
77+
6978
else : // URL submitted via bookmarklet, API, or mobile app
7079
$url = (isset($this->db_clean->url)) ? $this->db_clean->url : null;
7180
$title = (isset($this->db_clean->title)) ? $this->db_clean->title : null;
@@ -253,19 +262,33 @@ public function edit($mark_id=0)
253262
$options['notes'] = $this->db_clean->notes;
254263

255264
// Check for hashmarks to tags
256-
$tags = getTagsFromHash($options['notes']);
265+
//Removed in 2.0 $tags = getTagsFromHash($options['notes']);
266+
}
267+
268+
// If tags are present, set them
269+
if (isset($this->db_clean->tags)) {
270+
if ( $this->db_clean->tags == 'unmark:removeAllTags' ) { // Remove all tags by sending empty array
271+
$tags = array();
272+
parent::removeTags($mark_id);
273+
} else {
274+
$tags = explode( ',', $this->db_clean->tags );
275+
}
257276
}
258277

259278
// If tags are present, handle differently
260279
// Need to add to tags table first
261280
// Then create association
262281
// If notes are present set them
263-
if (isset($tags)) {
282+
if (isset($tags) && count($tags) > 0) {
264283
parent::addTags($tags, $mark_id);
265284
}
266285

267-
// Update users_to_marks record
268-
$mark = $this->user_marks->update("users_to_marks.user_id = '" . $this->user_id . "' AND users_to_marks.users_to_mark_id = '" . $mark_id . "'", $options);
286+
if ( isset($options) && count($options) > 0) {
287+
// Update users_to_marks record
288+
$mark = $this->user_marks->update("users_to_marks.user_id = '" . $this->user_id . "' AND users_to_marks.users_to_mark_id = '" . $mark_id . "'", $options);
289+
} else {
290+
$mark = $this->user_marks->readComplete($mark_id);
291+
}
269292

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

314337
public function get($what='stats')
315338
{
339+
log_message( 'DEBUG', 'Running get method for ' . $what );
340+
316341
parent::redirectIfWebView();
317342
$method = 'get' . ucwords($what);
318343

@@ -384,13 +409,14 @@ private function getStats()
384409

385410
}
386411

387-
// Get the 10 most used tags for a user
412+
// Get the 10 most used and most recent tags for a user
388413
private function getTags()
389414
{
390-
$this->data['tags'] = array();
391415
$this->load->model('user_marks_to_tags_model', 'user_tags');
392-
$this->data['tags']['popular'] = $this->user_tags->getPopular($this->user_id);
393-
$this->data['tags']['recent'] = $this->user_tags->getMostRecent($this->user_id);
416+
$this->data['tags'] = array();
417+
418+
$this->data['tags']['popular'] = $this->user_tags->getPopular($this->user_id);
419+
$this->data['tags']['recent'] = $this->user_tags->getMostRecent($this->user_id);
394420
}
395421

396422
// The index of the marks page
@@ -575,7 +601,7 @@ public function index()
575601
// Get stats, labels and tags
576602
// else skip this section and just return the marks
577603
if (parent::isWebView() === true) {
578-
self::getStats();
604+
//self::getStats();
579605
self::getLabels();
580606
self::getTags();
581607
}
@@ -611,11 +637,10 @@ public function info($mark_id=0)
611637
$this->data['no_header'] = true;
612638
$this->data['no_footer'] = true;
613639

614-
// print_r($_GET['bookmarklet']);
615-
// exit;
616-
617640
$this->data['bookmarklet'] = (isset($_GET['bookmarklet'])) ? $_GET['bookmarklet'] : true;
618641

642+
self::getTags();
643+
619644
// Figure view
620645
$this->figureView('marks/info');
621646
}

application/controllers/Tags.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public function index($page=1)
2525
// Read the complete user marks records
2626
$tags = $this->tags->read($where, $this->limit, $page);
2727

28-
// If no labels, return error
29-
// Else return labels
28+
// If no tags, return error
29+
// Else return tags
3030
if ($tags === false) {
3131
$this->data['errors'] = formatErrors(60);
3232
}
@@ -39,6 +39,27 @@ public function index($page=1)
3939
$this->figureView();
4040
}
4141

42+
// Used to get a list of popular and recent tags
43+
// Primarily used for tag autocompletion.
44+
public function getAutocomplete()
45+
{
46+
47+
$this->load->model('user_marks_to_tags_model', 'user_tags');
48+
$this->data['tags'] = array();
49+
$tags_popular = array();
50+
$tags_recent = array();
51+
52+
$tags_popular = $this->user_tags->getPopular($this->user_id);
53+
$tags_recent = $this->user_tags->getMostRecent($this->user_id);
54+
55+
if (is_array($tags_recent)) {
56+
$this->data['tags'] = array_merge( $tags_popular, $tags_recent);
57+
}
58+
59+
// Figure if web or API view
60+
$this->figureView();
61+
}
62+
4263
public function add()
4364
{
4465

application/core/Plain_Controller.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ protected function addMark($data=array())
192192

193193
}
194194

195+
protected function removeTags($mark_id)
196+
{
197+
$this->load->model('tags_model', 'tag');
198+
$this->load->model('user_marks_to_tags_model', 'mark_to_tag');
199+
200+
$delete = $this->mark_to_tag->delete("users_to_mark_id = '" . $mark_id . "' AND user_id = '" . $this->user_id . "'");
201+
}
202+
195203
protected function addTags($tags, $mark_id)
196204
{
197205
if (! empty($tags) && is_array($tags)) {

application/views/email/forgot-password.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
55
<title>Unmark // Reset Password</title>
66
<style type="text/css">
7-
@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Montserrat:400);
7+
@import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700);
88
99
/* Client-specific Styles */
1010
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
@@ -323,4 +323,4 @@
323323
<!-- End of preheader -->
324324
</div>
325325
326-
</body></html>
326+
</body></html>

application/views/email/update-password.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<meta name="viewport" content="width=device-width, initial-scale=1.0">
44
<title>Unmark // Password Updated</title>
55
<style type="text/css">
6-
@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Montserrat:400);
6+
@import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700);
77
88
/* Client-specific Styles */
99
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
@@ -340,4 +340,4 @@
340340
<!-- End of preheader -->
341341
</div>
342342
343-
</body></html>
343+
</body></html>

application/views/errors/html/error_404.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>Sorry, we can't find this page</title>
5-
<link href='http://fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
5+
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
66
<link rel="stylesheet" href="/assets/css/unmark.css">
77
<link rel="icon" type="image/ico" href="favicon.ico">
88
</head>

application/views/errors/html/error_db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>Eek, something is wrong</title>
5-
<link href='http://fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
5+
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
66
<link rel="stylesheet" href="/assets/css/unmark.css">
77
<link rel="icon" type="image/ico" href="/favicon.ico">
88
</head>

application/views/errors/html/error_general.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title>Eek, something is wrong</title>
5-
<link href='http://fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
5+
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
66
<link rel="stylesheet" href="/assets/css/unmark.css">
77
<link rel="icon" type="image/ico" href="/favicon.ico">
88
</head>

application/views/import/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
22
<head>
33
<title><?php echo unmark_phrase('Unmark : Importer'); ?></title>
4-
<link href='//fonts.googleapis.com/css?family=Lato:300,400|Merriweather' rel='stylesheet' type='text/css'>
4+
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700' rel='stylesheet' type='text/css'>
55
<link rel="stylesheet" href="/assets/css/unmark.css" />
66
<link rel="icon" type="image/ico" href="/favicon.ico" />
77
</head>

0 commit comments

Comments
 (0)