diff --git a/Gruntfile.js b/Gruntfile.js index 35251e4e..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: { @@ -163,7 +164,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 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/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/application/controllers/Export.php b/application/controllers/Export.php index efb5668a..a79eecf1 100644 --- a/application/controllers/Export.php +++ b/application/controllers/Export.php @@ -70,4 +70,89 @@ 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"; + + // 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){ + $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; + } + // Add single mark + } else if(!empty($pageResults)){ + + $singleMark = $pageResults; + + $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"; + + // Write the file as attachment + header('Content-type: text/html'); + header('Content-Disposition: attachment; filename=' . 'unmark-export.html'); + + echo $html; + } + } \ No newline at end of file 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); diff --git a/application/views/layouts/userforms.php b/application/views/layouts/userforms.php index c7666278..a2bc50f5 100644 --- a/application/views/layouts/userforms.php +++ b/application/views/layouts/userforms.php @@ -31,9 +31,15 @@
-

+

- +
+ +
+
+ +
+

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.'); ?>

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'); 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.", diff --git a/readme.md b/readme.md index 99bb5831..df664f9d 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,21 +103,21 @@ 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. ### 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_! 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