Skip to content

Commit

Permalink
Update to also work with oC6
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghus committed Feb 25, 2014
1 parent b3a3b9b commit eb88ea6
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 29 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<author>Thomas Tanghus</author>
<require>4.93</require>
<shipped>false</shipped>
<version>0.3.2</version>
<version>0.3.3</version>
<description>Journal view from calendar</description>
</info>
7 changes: 7 additions & 0 deletions css/icons.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.delete { background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; }
.edit { background:url('%webroot%/core/img/actions/rename.svg') no-repeat center; }
.share { background:url('%webroot%/core/img/actions/share.svg') no-repeat center; }
.mail { background:url('%webroot%/core/img/actions/mail.svg') no-repeat center; }
.download { background:url('%webroot%/core/img/actions/download.svg') no-repeat center; }
.globe { background:url('%webroot%/core/img/actions/public.svg') no-repeat center; }
.cog { background:url('%webroot%/core/img/actions/settings.svg') no-repeat center; float: right; }
11 changes: 1 addition & 10 deletions css/journal.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,7 @@ input { font-size: 1em; font-weight: bold; }
#actions { float: right; padding-right: 1em; }
#actions a { display: inline-block; width: 16px; height: 16px; opacity: 0.5; padding: 0 0.3em; }
#actions a:hover { opacity: 1; }
.add { background:url('%webroot%/core/img/actions/add.svg') no-repeat center; clear: both; }
.delete { background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; }
.edit { background:url('%webroot%/core/img/actions/rename.svg') no-repeat center; }
.share { background:url('%webroot%/core/img/actions/share.svg') no-repeat center; }
.mail { background:url('%webroot%/core/img/actions/mail.svg') no-repeat center; }
.upload { background:url('%webroot%/core/img/actions/upload.svg') no-repeat center; }
.download { background:url('%webroot%/core/img/actions/download.svg') no-repeat center; }
.cloud { background:url('%webroot%/core/img/places/picture.svg') no-repeat center; }
.globe { background:url('%webroot%/core/img/actions/public.svg') no-repeat center; }
.cog { background:url('%webroot%/core/img/actions/settings.svg') no-repeat center; float: right; }
.cog { float: right; }
.drop { margin-right: 0.5em !important; }
#settings_status { padding: 0.2em; font-weight: bold; float: left; border-radius: 3px; }
#firstrun {
Expand Down
15 changes: 13 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

if(count($errors) == 0) {
$categories = OC_Calendar_App::getCategoryOptions();
$categories = OCA\Journal\App::getCategories();
$calendars = array();
$singlecalendar = (bool)OCP\Config::getUserValue(OCP\User::getUser(), 'journal', 'single_calendar', false);
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
Expand All @@ -48,16 +48,26 @@
// Load a specific entry?
$id = isset($_GET['id']) ? $_GET['id'] : null;

// Version check
list($version,) = \OCP\Util::getVersion();

OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addScript('contacts','jquery.multi-autocomplete');
OCP\Util::addScript('','oc-vcategories');
if($version < 6) {
OCP\Util::addScript('','oc-vcategories');
} else {
OCP\Util::addScript('','tags');
}
OCP\Util::addScript('journal', 'jquery.rte');
OCP\Util::addScript('journal', 'jquery.textchange');
OCP\Util::addScript('journal', 'journal');
OCP\Util::addscript('tal','modernizr');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('journal', 'rte');
OCP\Util::addStyle('journal', 'journal');
if($version < 6) {
OCP\Util::addStyle('journal', 'icons');
}
OCP\App::setActiveNavigationEntry('journal_index');
}

Expand All @@ -71,5 +81,6 @@
$tmpl->assign('calendars', $calendars);
$tmpl->assign('singlecalendar', $singlecalendar);
$tmpl->assign('id', $id);
$tmpl->assign('version', $version);
}
$tmpl->printPage();
26 changes: 22 additions & 4 deletions js/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,20 @@ String.prototype.zeroPad = function(digits) {

OC.Journal = {
categories:undefined,
version:undefined,
init:function() {
var self = this;
this.version = $('#journal-content').data('version');
if(this.version < 6) {
OCCategories.changed = OC.Journal.categoriesChanged;
OCCategories.app = 'journal';
} else {
$(OC.Tags).on('change', function(event, data) {
if(data.type === 'journal') {
self.categoriesChanged(data.tags);
}
});
}
this.setEnabled(false);
// Fetch journal entries. If it's a direct link 'id' will be loaded.
var id = parseInt(window.location.hash.substr(1));
Expand Down Expand Up @@ -124,7 +136,11 @@ OC.Journal = {
}
},
categoriesChanged:function(newcategories) { // Categories added/deleted.
this.categories = $.map(newcategories, function(v) {return v;});
if(this.version < 6) {
this.categories = $.map(newcategories, function(v) {return v;});
} else {
this.categories = $.map(newcategories, function(v) {return v.name;});
}
$('#categories').multiple_autocomplete('option', 'source', this.categories);
},
propertyContainerFor:function(obj) {
Expand Down Expand Up @@ -567,8 +583,6 @@ OC.Journal = {
};

$(document).ready(function(){
OCCategories.changed = OC.Journal.categoriesChanged;
OCCategories.app = 'journal';

// Initialize controls.
$('#categories').multiple_autocomplete({source: OC.Journal.categories});
Expand Down Expand Up @@ -666,7 +680,11 @@ $(document).ready(function(){

$('#metadata').on('click', '#editcategories', function(event) {
$(this).tipsy('hide');
OCCategories.edit();
if(OC.Journal.version < 6) {
OCCategories.edit();
} else {
OC.Tags.edit('journal');
}
});

$('#metadata').on('click', '#delete', function(event) {
Expand Down
6 changes: 5 additions & 1 deletion js/jquery.rte.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $.widget( 'ui.rte', {
});
},
text: function(str) {
console.log('function text');
console.log('function text', str);
if(str != undefined) {
this.mirror.html(str);
this.element.val(str);
Expand Down Expand Up @@ -215,7 +215,11 @@ $.widget( 'ui.rte', {
this.mirror.trigger('change');
break;
case 'text':
try {
this.element.val($(this.mirror.html().replace(/<br>/g, "\n")).text());
} catch(e) {
console.warn('Exception:', e);
}
this.mirror.hide();
this.element.show();
this.element.trigger('resize');
Expand Down
36 changes: 31 additions & 5 deletions lib/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,21 @@ public static function getDefaultCategories() {
* @return (object) $vcategories
*/
protected static function getVCategories() {
// Version check
list($version,) = \OCP\Util::getVersion();

if (is_null(self::$categories)) {
self::$categories = new \OC_VCategories('journal', null, self::getDefaultCategories());
if($version < 6) {
self::$categories = new \OC_VCategories('journal', null, self::getDefaultCategories());
} else {
$categories = \OC::$server->getTagManager()->load('journal');
if($categories->isEmpty('journal')) {
self::scanCategories();
}
self::$categories = \OC::$server->getTagManager()
->load('journal', self::getDefaultCategories());
}

}
return self::$categories;
}
Expand All @@ -222,23 +235,36 @@ protected static function getVCategories() {
* @brief returns the categories of the vcategories object
* @return (array) $categories
*/
public static function getCategoryOptions(){
$categories = self::getVCategories()->categories();
public static function getCategories(){
// Version check
list($version,) = \OCP\Util::getVersion();

if($version < 6) {
$categories = self::getVCategories()->categories();
} else {

$getNames = function($tag) {
return $tag['name'];
};
$categories = self::getVCategories()->getTags();
$categories = array_map($getNames, $categories);
}

return $categories;
}

/**
* @brief returns the categories for the user
* @return (Array) $categories
*/
public static function getCategories() {
/*public static function getCategories() {
$categories = self::getVCategories()->categories();
if(count($categories) == 0) {
self::scanCategories();
$categories = self::$categories->categories();
}
return ($categories ? $categories : self::getDefaultCategories());
}
}*/

/**
* scan journals for categories.
Expand Down
12 changes: 6 additions & 6 deletions templates/index.pt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="content" i18n:domain="journal">
<div id="journal-content" tal:attributes="data-version version" i18n:domain="journal">
<div id="controls">
<select class="tip" id="entrysort" title="Sort journal entries" i18n:attributes="title">
<option value="dtasc" i18n:translate="">Date - ascending</option>
Expand All @@ -13,7 +13,7 @@
<input class="property" id="daterangeto" name="value" type="date" size="10" autocomplete="off" placeholder="yyyy-mm-dd" value="" i18n:attributes="placeholder" disabled="true" />
<input type="checkbox" id="daterangesort" />
<label for="daterangesort" title="Only show entries between these days." i18n:attributes="title" i18n:translate="">Filter by date</label>
<a class="cog" title="Settings" i18n:attributes="title"></a>
<a class="icon icon-settings cog" title="Settings" i18n:attributes="title"></a>
</div>
<div id="leftcontent" class="hascontrols">
<ul id="entries"></ul>
Expand Down Expand Up @@ -66,10 +66,10 @@
<div>
<input type="checkbox" id="editable" /><label class="tip" for="editable" title="Set this journal entry in edit mode" i18n:attributes="title" i18n:translate="">Edit</label>
<span id="actions">
<a class="download" id="export" title="Export as iCal file" i18n:attributes="title"></a>
<a class="globe" id="showlink" title="Direct link to this journal entry" i18n:attributes="title"></a>
<a class="share" title="Sharing" i18n:attributes="title" data-item-type="journal"></a>
<a class="delete" id="delete" title="Delete this journal entry" i18n:attributes="title"></a>
<a class="icon icon-download download" id="export" title="Export as iCal file" i18n:attributes="title"></a>
<a class="icon icon-public globe" id="showlink" title="Direct link to this journal entry" i18n:attributes="title"></a>
<a class="icon icon-share share" title="Sharing" i18n:attributes="title" data-item-type="journal"></a>
<a class="icon icon-delete delete" id="delete" title="Delete this journal entry" i18n:attributes="title"></a>
</span>
<input class="hidden" id="link" type="text" />
</div>
Expand Down

0 comments on commit eb88ea6

Please sign in to comment.