From 9ab75b19ff37ba0592bd34bf2614078e12109aef Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Tue, 16 Jun 2020 08:41:15 -0400 Subject: [PATCH 1/9] Updated version number. Fixes #265 --- application/config/config.php | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 53eb2453..698fa066 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -11,7 +11,7 @@ | version.point.release | */ -$config['unmark_version'] = '2020.1'; +$config['unmark_version'] = '2020.3'; /* |-------------------------------------------------------------------------- diff --git a/package.json b/package.json index bb0950fe..fc8942a5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unmark", "url": "https://unmark.it", - "version": "2.0.0", + "version": "2020.3.0", "repository": "https://github.com/cdevroe/unmark", "license": "https://github.com/cdevroe/unmark/blob/master/license.txt", "description": "The open source to-do application for bookmarks.", From edad681c8b09e8b449870de24f320fac0856db74 Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Wed, 24 Jun 2020 14:42:32 -0400 Subject: [PATCH 2/9] Added new HTML export format. Supports the Netscape HTML export spec, the same spec that Unmark already imports. Export include titles, tags, and notes. Addresses #263 --- application/controllers/Export.php | 109 ++++++++++++++++++++++++ application/views/layouts/userforms.php | 9 +- assets/css/partials/_overlays.scss | 2 +- assets/js/unmark.client.js | 7 +- 4 files changed, 123 insertions(+), 4 deletions(-) diff --git a/application/controllers/Export.php b/application/controllers/Export.php index efb5668a..5bbf6f26 100644 --- a/application/controllers/Export.php +++ b/application/controllers/Export.php @@ -70,4 +70,113 @@ public function index() } } + /** + * Generate HTML export file for current user + * Spec: Based on Netscape / Firefox export HTML + */ + public function html() + { + + $html = " + + + Unmark Export +

Bookmarks

" . "\n\n"; + + $html .= "
" . "\n"; + // Enable export library + $this->load->library('JSONExport'); + // Add import version info + //$this->jsonexport->addMeta('export_version', self::EXPORT_FILE_VERSION); + //$this->jsonexport->addMeta('export_date', date('Y-m-d H:i:s')); + // Retrieve user marks + $this->load->model('users_to_marks_model', 'user_marks'); + $where = 'users_to_marks.user_id='. $this->user_id; + $marksCount = $this->user_marks->count($where); + // Number of marks + //$this->jsonexport->addMeta('marks_count', $marksCount); + $pages = ceil((double) $marksCount / (double) self::PAGE_SIZE); + // Get page of data + for($curPage=1;$curPage<=$pages;$curPage++){ + $pageResults = $this->user_marks->readComplete($where, self::PAGE_SIZE, $curPage); + + // Add all retrieved marks + if(is_array($pageResults)){ + foreach($pageResults as $key=>$singleMark){ + + //$this->jsonexport->addMark($singleMark); + //print_r($key); + //print_r($singleMark); + $html .= "
url . "\" + ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; + if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : + //print_r($singleMark->tags); + $tags = ""; + + foreach($singleMark->tags as $tag=>$meta) { + $tags .= $tag . ","; + } + + $html .= " TAGS=" . $tags; + endif; + + $html .= ">" . $singleMark->title . "" . "\n"; + + if ( !empty($singleMark->notes) ) : + $html .= "
" . $singleMark->notes . "\n\n"; + else : + $html .= "\n"; + endif; + } + // Add single mark + } else if(!empty($pageResults)){ + + //$this->jsonexport->addMark($pageResults); + $singleMark = $pageResults; + //$this->jsonexport->addMark($singleMark); + //print_r($key); + //print_r($singleMark); + $html .= "
url . "\" + ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; + if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : + //print_r($singleMark->tags); + $tags = ""; + + foreach($singleMark->tags as $tag=>$meta) { + $tags .= $tag . ","; + } + + $html .= " TAGS=" . $tags; + endif; + + $html .= ">" . $singleMark->title . "" . "\n"; + + if ( !empty($singleMark->notes) ) : + $html .= "
" . $singleMark->notes . "\n\n"; + else : + $html .= "\n"; + endif; + } + } + + $html .= "
" . "\n\n"; + + echo $html; + exit; + + // Write the file as attachment + //$file = $this->jsonexport->getFileForOutput(); + header('Content-type: text/html'); + header('Content-Disposition: attachment; filename=' . 'unmark-export.html'); + + echo $html; + //while (!$file->eof()) { + // $this->output->append_output($file->fgets()); + //} + } + } \ No newline at end of file diff --git a/application/views/layouts/userforms.php b/application/views/layouts/userforms.php index c7666278..6352a4de 100644 --- a/application/views/layouts/userforms.php +++ b/application/views/layouts/userforms.php @@ -31,9 +31,14 @@
-

+

- +
+ +
+
+ +
diff --git a/assets/css/partials/_overlays.scss b/assets/css/partials/_overlays.scss index 0379ab98..ff9d8270 100644 --- a/assets/css/partials/_overlays.scss +++ b/assets/css/partials/_overlays.scss @@ -7,7 +7,7 @@ padding-bottom: 20px; } } - .from-unmark, .from-other { + .from-unmark, .from-other, .to-html, .to-unmark { padding: 0 0 12px; p { font-size: 12px; diff --git a/assets/js/unmark.client.js b/assets/js/unmark.client.js index 816caede..c690b5fc 100644 --- a/assets/js/unmark.client.js +++ b/assets/js/unmark.client.js @@ -97,11 +97,16 @@ } }; - // Export Data + // Export Data to Unmark unmark.export_data = function () { return window.location.href = "/export"; }; + // Export Data to HTML + unmark.export_data_html = function () { + return window.location.href = "/export/html"; + }; + // Import Data unmark.import_data = function () { return $('#importerUnmark').trigger('click'); From 39f634d02fe381e3fefdeb7aba1c5bdf0434c5bd Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Wed, 24 Jun 2020 15:10:23 -0400 Subject: [PATCH 3/9] Bug fixes for HTML export --- application/controllers/Export.php | 68 ++++++++----------------- application/views/layouts/userforms.php | 1 + 2 files changed, 23 insertions(+), 46 deletions(-) diff --git a/application/controllers/Export.php b/application/controllers/Export.php index 5bbf6f26..a79eecf1 100644 --- a/application/controllers/Export.php +++ b/application/controllers/Export.php @@ -86,11 +86,7 @@ public function html()

Bookmarks

" . "\n\n"; $html .= "
" . "\n"; - // Enable export library - $this->load->library('JSONExport'); - // Add import version info - //$this->jsonexport->addMeta('export_version', self::EXPORT_FILE_VERSION); - //$this->jsonexport->addMeta('export_date', date('Y-m-d H:i:s')); + // Retrieve user marks $this->load->model('users_to_marks_model', 'user_marks'); $where = 'users_to_marks.user_id='. $this->user_id; @@ -105,22 +101,15 @@ public function html() // Add all retrieved marks if(is_array($pageResults)){ foreach($pageResults as $key=>$singleMark){ - - //$this->jsonexport->addMark($singleMark); - //print_r($key); - //print_r($singleMark); - $html .= "
url . "\" - ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; + $html .= "
url . "\" ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : - //print_r($singleMark->tags); $tags = ""; foreach($singleMark->tags as $tag=>$meta) { $tags .= $tag . ","; } - $html .= " TAGS=" . $tags; + $html .= " TAGS=\"" . $tags . "\" "; endif; $html .= ">" . $singleMark->title . "" . "\n"; @@ -134,49 +123,36 @@ public function html() // Add single mark } else if(!empty($pageResults)){ - //$this->jsonexport->addMark($pageResults); $singleMark = $pageResults; - //$this->jsonexport->addMark($singleMark); - //print_r($key); - //print_r($singleMark); - $html .= "
url . "\" - ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; - if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : - //print_r($singleMark->tags); - $tags = ""; - - foreach($singleMark->tags as $tag=>$meta) { - $tags .= $tag . ","; - } - - $html .= " TAGS=" . $tags; - endif; - - $html .= ">" . $singleMark->title . "" . "\n"; - - if ( !empty($singleMark->notes) ) : - $html .= "
" . $singleMark->notes . "\n\n"; - else : - $html .= "\n"; - endif; + + $html .= "
url . "\" ADD_DATE=\"" . strtotime( $singleMark->created_on ) . "\""; + if ( !empty($singleMark->tags) && count($singleMark->tags) > 0 ) : + $tags = ""; + + foreach($singleMark->tags as $tag=>$meta) { + $tags .= $tag . ","; + } + + $html .= " TAGS=\"" . $tags . "\" "; + endif; + + $html .= ">" . $singleMark->title . "" . "\n"; + + if ( !empty($singleMark->notes) ) : + $html .= "
" . $singleMark->notes . "\n\n"; + else : + $html .= "\n"; + endif; } } $html .= "
" . "\n\n"; - - echo $html; - exit; // Write the file as attachment - //$file = $this->jsonexport->getFileForOutput(); header('Content-type: text/html'); header('Content-Disposition: attachment; filename=' . 'unmark-export.html'); echo $html; - //while (!$file->eof()) { - // $this->output->append_output($file->fgets()); - //} } } \ No newline at end of file diff --git a/application/views/layouts/userforms.php b/application/views/layouts/userforms.php index 6352a4de..a2bc50f5 100644 --- a/application/views/layouts/userforms.php +++ b/application/views/layouts/userforms.php @@ -39,6 +39,7 @@
+

From c95b2a5b2400244d8ff07b479031ba3026722025 Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Thu, 25 Jun 2020 10:08:13 -0400 Subject: [PATCH 4/9] Added method to Plain controller to redirect to Unmark setup process if no tables exist yet. Fixes #266 --- application/controllers/Welcome.php | 3 +++ application/core/Plain_Controller.php | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/application/controllers/Welcome.php b/application/controllers/Welcome.php index 5c53a8ba..b6c9ece9 100644 --- a/application/controllers/Welcome.php +++ b/application/controllers/Welcome.php @@ -11,6 +11,9 @@ public function __construct() public function index() { $this->redirectIfLoggedIn('/marks'); + $this->redirectIfNotInstalled('/setup'); + + $this->view('welcome', array('no_header' => true, 'no_footer' => true)); } diff --git a/application/core/Plain_Controller.php b/application/core/Plain_Controller.php index b082b86d..62721252 100644 --- a/application/core/Plain_Controller.php +++ b/application/core/Plain_Controller.php @@ -531,6 +531,18 @@ protected function redirectIfWebView($url='/') } } + // If no tables exist, redirect to install + protected function redirectIfNotInstalled($url='/setup') + { + $this->load->database(); + $query = $this->db->query("SHOW TABLES LIKE 'users'"); + $result = $query->result(); + if ( count($result) == 0 ) : + header('Location: ' . $url); + exit; + endif; + } + public function renderJSON() { $json = json_encode($this->data, JSON_FORCE_OBJECT); From 61faa7aeaa12cbef714791d4aa5f71bcd95ead90 Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Mon, 5 Oct 2020 15:20:54 -0400 Subject: [PATCH 5/9] Fixed a typo. --- application/views/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/setup.php b/application/views/setup.php index 68c4c39d..41b90f6f 100644 --- a/application/views/setup.php +++ b/application/views/setup.php @@ -20,7 +20,7 @@
-

config->item('unmark_version') . ' of the app.

Please read the installation instructions first.'); ?>

+

config->item('unmark_version') . ' of the app.

Please read the installation instructions first.'); ?>

From 2f7627e4a720f130fcdfc9d07b990f287dcfe4d0 Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Mon, 5 Oct 2020 15:32:20 -0400 Subject: [PATCH 6/9] Removed unused grunt task --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 35251e4e..b76d6999 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -163,7 +163,7 @@ module.exports = function(grunt) { // 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('production', [ 'makeCustom', 'sass:prod', 'uglify:prod' ]); // Utility tasks that deletes/copies /custom/ grunt.registerTask( 'makeCustom', [ 'clean:custom', 'copy:custom' ] ); // Copies ../unmark-internal/custom to ../unmark/custom From 5116cbff74600850dfa91c44bf534470386924be Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Tue, 6 Oct 2020 11:59:03 -0400 Subject: [PATCH 7/9] Updated Grunt production task to copy production JS file into appropriate place for local custom development. Only applicable for those running a custom folder. --- Gruntfile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index b76d6999..fffa25f1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -86,7 +86,8 @@ module.exports = function(grunt) { copy: { custom: { files: [ - {expand: true, flatten: false, cwd: '../unmark-internal/custom/', src: ['**'], dest: '../unmark/custom/'} + {expand: true, flatten: false, cwd: '../unmark-internal/custom/', src: ['**'], dest: '../unmark/custom/'}, + {expand: true, flatten: true, src: 'assets/js/production/unmark.loggedin.js', dest: '../unmark/custom/assets/js/production/'} ] }, release: { From 391a505d2788316cc4c5aef77b60d489621d95c9 Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Tue, 6 Oct 2020 12:23:51 -0400 Subject: [PATCH 8/9] Updated database sample config file to include credentials for database that ships with Docker. Fixes #267 --- application/config/database-sample.php | 6 +- readme.md | 76 ++++++++++++++++++-------- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/application/config/database-sample.php b/application/config/database-sample.php index 418b2ae8..32804a89 100644 --- a/application/config/database-sample.php +++ b/application/config/database-sample.php @@ -52,9 +52,9 @@ $query_builder = TRUE; -$db['default']['hostname'] = 'localhost'; -$db['default']['username'] = 'username'; -$db['default']['password'] = 'password'; +$db['default']['hostname'] = 'unmark_mysql'; +$db['default']['username'] = 'unmarkuser'; +$db['default']['password'] = 'unmarkpass'; $db['default']['database'] = 'unmark'; $db['default']['dbdriver'] = 'mysqli'; // $db['default']['dbprefix'] = ''; # Do not use, see: https://github.com/plainmade/unmark/issues/62 diff --git a/readme.md b/readme.md index 99bb5831..6d36c65c 100644 --- a/readme.md +++ b/readme.md @@ -18,13 +18,14 @@ Running Unmark is only recommended for intermediate users. This doesn't mean if ### Technical requirements +It is now recommended to use Docker / Docker Compose to install and run Unmark locally both for personal use and for development. Please see the installation instructions section below. + +However, if you're going to run your own server: + - Apache 2.x - PHP 5.6 or greater - mySQL 5.7 or greater -** Using Docker to run locally** -If know how to use Docker we've included the appropriate Docker Compose, Dockerfile, and PHP.ini files to do so. We've been using Docker on both Windows and Mac for the last two releases and we like it. However, this is still in its experimental phase. - ### Common Issues Some common issues have been reported. Some are trying to load Unmark on a sub-directory, using different versions of PHP or Apache, or using completely different databases. While it may be possible to do so, expect issues. @@ -35,41 +36,63 @@ Other common things that come up: ### Installation Instructions -#### From Zip +#### With Docker / Docker Compose + +We've included the appropriate Docker Compose, Dockerfile, and PHP.ini files to run Unmark locally on Windows or Mac with almost zero set up. We've been using Docker on both Windows and Mac for the last two releases and we like it. However, this is still in its early phases so please report any issues that you find. + +**Warning:** Running `docker-compose down -v` will erase Docker volumes including your local database. If you do not include the -v argument your database will remain intact. If you need to run -v log into Unmark and export your marks first. + +### How to start Unmark via Docker for personal use +- Download and install [Docker](https://docs.docker.com/get-docker/) +- Download and install [Docker Compose](https://docs.docker.com/compose/install/) - Download [the latest release](https://github.com/cdevroe/unmark/releases) - Unpack the archive into your desired location - Rename the file `/application/config/database-sample.php` to `/application/config/database.php` -- Create a database for Unmark to use in mySQL -- Fill in proper database credentials in `/application/config/database.php` -- Point your browser to `your-local-url/setup` -- If succesfull, you'll be asked to register a username and password +- In Terminal or Powershell - Run `docker-compose up -d` (to shut Unmark down run `docker-compose down`) +- Navigate to [http://localhost](http://localhost) and click "Install" +- If successful, you'll be asked to create an account -#### From git repository +#### From start Unmark via Docker for development +- Download and install [Docker](https://docs.docker.com/get-docker/) +- Download and install [Docker Compose](https://docs.docker.com/compose/install/) - Run `git clone https://github.com/cdevroe/unmark.git` (Or, if you've forked the repo, use your URL) -- Copy the file `/application/config/database-sample.php` to `/application/config/database.php` (leave `database-sample.php` in place) -- Create a database for Unmark to use in mySQL -- Fill in proper database credentials in `/application/config/database.php` +- **Copy the file** `/application/config/database-sample.php` to `/application/config/database.php` (leave `database-sample.php` in place) +- Rename the file `/application/config/database-sample.php` to `/application/config/database.php` +- Run `docker-compose up -d` (to shut Unmark down run `docker-compose down`) - Run `npm install` - Run `grunt` [more info on Grunt](http://gruntjs.com/) - - To run Grunt you'll need to also install Ruby and the SASS gem + - To run Grunt you'll need to also install Ruby and the [SASS gem](https://sass-lang.com/ruby-sass) +- Navigate to [http://localhost](http://localhost) and click "Install" +- If successful, you'll be asked to create an account + +#### How to start Unmark from Zip on your own server for personal use + +No longer recommended, but do whatever you want! + +- Download [the latest release](https://github.com/cdevroe/unmark/releases) +- Unpack the archive into your desired location +- Rename the file `/application/config/database-sample.php` to `/application/config/database.php` +- Create a database for Unmark to use in mySQL +- Fill in proper database credentials in `/application/config/database.php` - Point your browser to `your-local-url/setup` -- If successful, you'll be asked to register a username and password +- If succesfull, you'll be asked to register a username and password ### Upgrading to the latest release -#### From Zip (binary) +#### From Release - Download [the latest release](https://github.com/cdevroe/unmark/releases) +- Shut down Unmark `docker-compose down` - Replace all Unmark files (keeping your local `/application/config/database.php` intact.) -- Navigate to `your-local-url/upgrade` -- Unmark will then make any needed database updates +- Navigate to [http://localhost/upgrade](http://localhost/upgrade) +- Unmark will then make any database updates if needed - That's it! #### From git repository -- Run `git pull origin master` +- Run `git pull origin trunk` - Run `npm update` in the app's root directory - Run `grunt` in the app's root directory -- Navigate to `your-local-url/upgrade` -- Unmark will then make any needed database updates +- Navigate to [http://localhost/upgrade](http://localhost/upgrade) +- Unmark will then make any database updates if needed - That's it! ### Importing bookmarks @@ -80,7 +103,7 @@ To ensure this works properly be sure that your PHP.ini file's "max_upload_size" ## How to contribute to Unmark -Please consider donating. Another major way you can contribute is to report any issues you find with Unmark on Github and being as detailed as possible about the issue you're having. +Please consider [donating via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XSYNN4MGM826N). Another major way you can contribute is to report any issues you find with Unmark on Github and being as detailed as possible about the issue you're having. Another way is to contribute your own code via Pull Requests. Here are some notes on how to do that. @@ -94,7 +117,7 @@ Another way is to contribute your own code via Pull Requests. Here are some note This makes it easy for us to test your code locally and also allows the community to have a discussion around it. -We use [Grunt](http://gruntjs.com/) to compile our SASS files into CSS and concatenate and compress our JavaScript files for use and a few other small tasks. For any updates to JavaScript or styles you will need to use Grunt too. See the Grunt web site for help. +We use [Grunt](http://gruntjs.com/) to compile our SASS files into CSS and concatenate and compress our JavaScript files for use and a few other small tasks. For any updates to JavaScript or styles you will need to use Grunt too. See the Grunt web site for help. We'd like to someday move away from Grunt for most of these tasks. ## History @@ -106,6 +129,11 @@ Now it is being maintained by Colin, Kyle and the community in their spare time. Currently being maintained by: [@cdevroe](https://github.com/cdevroe) and [@kyleruane](https://github.com/kyleruane). -Also contributions by [@thebrandonallen](https://github.com/thebrandonallen), [@simonschaufi](https://github.com/simonschaufi), [@williamknauss](https://github.com/williamknauss), [@hewigovens](https://github.com/hewigovens) +Extra special thanks to: + +- [@phpfunk](https://github.com/phpfunk) - who wrote most of Unmark's original codebase +- [@twhitacre](https://github.com/twhitacre) +- [@kip9](https://github.com/kip9) - wrote the languages and migration back-up bits +- [@cfehnel](https://github.com/cfehnel) - who handled support for the app -Extra special thanks to: [@phpfunk](https://github.com/phpfunk) (who wrote most of Unmark), [@twhitacre](https://github.com/twhitacre), [@kip9](https://github.com/kip9) (wrote the languages and migration back-up bits), [@cfehnel](https://github.com/cfehnel) (who handled support for the app). +Also contributions by [@thebrandonallen](https://github.com/thebrandonallen), [@simonschaufi](https://github.com/simonschaufi), [@williamknauss](https://github.com/williamknauss), [@hewigovens](https://github.com/hewigovens) \ No newline at end of file From a49a3dff3255f8a2c15a928b452c7695ec404386 Mon Sep 17 00:00:00 2001 From: Colin Devroe Date: Tue, 6 Oct 2020 12:31:41 -0400 Subject: [PATCH 9/9] Updated readme where master was found. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6d36c65c..df664f9d 100644 --- a/readme.md +++ b/readme.md @@ -110,7 +110,7 @@ Another way is to contribute your own code via Pull Requests. Here are some note ### Forking and Pull Requests - Fork [the repository on GitHub](https://github.com/cdevroe/unmark/) into your own account -- Create your own branch of the master branch `git checkout -b your-branch-name` +- Create your own branch of the trunk branch `git checkout -b your-branch-name` - Update your code and push those code changes back to your fork's branch `git push origin your-branch-name` - [Submit a Pull Request](https://github.com/cdevroe/unmark/pulls) using that branch - And please accept our _thanks_!