Skip to content

Commit

Permalink
Merge pull request #268 from cdevroe/proposals/v2020.3
Browse files Browse the repository at this point in the history
Merged PR Version 2020.3
  • Loading branch information
cdevroe committed Oct 6, 2020
2 parents 76ff92d + a49a3df commit be515ef
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 37 deletions.
5 changes: 3 additions & 2 deletions Gruntfile.js
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion application/config/config.php
Expand Up @@ -11,7 +11,7 @@
| version.point.release
|
*/
$config['unmark_version'] = '2020.1';
$config['unmark_version'] = '2020.3';

/*
|--------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions application/config/database-sample.php
Expand Up @@ -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
Expand Down
85 changes: 85 additions & 0 deletions application/controllers/Export.php
Expand Up @@ -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 = "<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">
<TITLE>Unmark Export</TITLE>
<H1>Bookmarks</H1>" . "\n\n";

$html .= "<DL>" . "\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 .= "<DT><A HREF=\"" . $singleMark->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 . "</A>" . "\n";

if ( !empty($singleMark->notes) ) :
$html .= "<DD>" . $singleMark->notes . "\n\n";
else :
$html .= "\n";
endif;
}
// Add single mark
} else if(!empty($pageResults)){

$singleMark = $pageResults;

$html .= "<DT><A HREF=\"" . $singleMark->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 . "</A>" . "\n";

if ( !empty($singleMark->notes) ) :
$html .= "<DD>" . $singleMark->notes . "\n\n";
else :
$html .= "\n";
endif;
}
}

$html .= "</DL>" . "\n\n";

// Write the file as attachment
header('Content-type: text/html');
header('Content-Disposition: attachment; filename=' . 'unmark-export.html');

echo $html;
}

}
3 changes: 3 additions & 0 deletions application/controllers/Welcome.php
Expand Up @@ -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));
}

Expand Down
12 changes: 12 additions & 0 deletions application/core/Plain_Controller.php
Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions application/views/layouts/userforms.php
Expand Up @@ -31,9 +31,15 @@
<div class="loginInner">
<div class="export">
<header>
<h1><?php echo unmark_phrase('Export All Marks') ?></h1>
<h1><?php echo unmark_phrase('Exporting Marks') ?></h1>
</header>
<a data-action="export_data" class="exportbtn action" href="#"><?php echo unmark_phrase('Export File') ?></a>
<div class="to-unmark">
<a data-action="export_data" class="exportbtn action" href="#"><?php echo unmark_phrase('Export Unmark File') ?></a>
</div>
<div class="to-html">
<a data-action="export_data_html" class="exportbtn action" href="#"><?php echo unmark_phrase('Export HTML File') ?></a>
</div>
<p class="note"><em><?php echo unmark_phrase('Note: HTML export is compatible with Pocket, Delicious, Pinboard, and others.'); ?></em></p>
</div>
<div class="import">
<header>
Expand Down
2 changes: 1 addition & 1 deletion application/views/setup.php
Expand Up @@ -20,7 +20,7 @@

<div id="unmark-setup">

<p><?php echo unmark_phrase('Welcome to Unmark, the to-do app for bookmarks.'); ?><?php echo unmark_phrase('You\'re about to install version ' . $this->config->item('unmark_version') . ' of the app.</p><p>Please <a href="https://github.com/plainmade/unmark/blob/master/readme.md">read the installation instructions</a> first.'); ?></p>
<p><?php echo unmark_phrase('Welcome to Unmark, the to-do app for bookmarks.'); ?> <?php echo unmark_phrase('You\'re about to install version ' . $this->config->item('unmark_version') . ' of the app.</p><p>Please <a href="https://github.com/plainmade/unmark/blob/master/readme.md">read the installation instructions</a> first.'); ?></p>

<a class="abtn" href="/install"><?php echo unmark_phrase('Click to Install') ?></a>

Expand Down
2 changes: 1 addition & 1 deletion assets/css/partials/_overlays.scss
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion assets/js/unmark.client.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion 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.",
Expand Down
78 changes: 53 additions & 25 deletions readme.md
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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)

0 comments on commit be515ef

Please sign in to comment.