Skip to content

Commit

Permalink
portfolio detail enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnycrab committed Jun 29, 2013
1 parent 2819d30 commit 15361db
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 36 deletions.
4 changes: 4 additions & 0 deletions app/app/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ require [
else
return block.inverse @

Handlebars.registerHelper 'console', (what) ->
console.log what
'logging...'


# ! KICK OFF

Expand Down
4 changes: 4 additions & 0 deletions app/app/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions app/app/modules/Portfolio.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ define [
template: 'packery-list-item'
serialize: () ->
data = if @.model then @.model.toJSON() else {}
data.Persons = _.sortBy json.Persons, (person) ->
return person.Surname

data.LinkTo = @.options.linkTo
data

Expand All @@ -42,13 +45,19 @@ define [
$doc.trigger(@._codeEv)
$doc.trigger(@._afterRenderEv)
serialize: ->

json = if @.model then @.model.toJSON() else {}
types = ['Projects', 'ChildProjects', 'ParentProjects']

# check for person group length
if json.Persons.length > Portfolio.Config.person_group_length
# sort persons
json.Persons = _.sortBy json.Persons, (person) ->
return person.Surname

if parseInt(json.Persons.length) > parseInt(Portfolio.Config.person_group_length)
#json.IsGroupProjectTop = true
json.IsGroup = true

console.log json
# set up combined projects
json.combinedProjects = []
_.each types, (type) =>
Expand All @@ -61,16 +70,15 @@ define [

Handlebars.registerHelper 'nameSummary', (persons) ->
conf = Portfolio.Config
return conf.group_project_title unless persons.length < conf.person_group_length
return conf.group_project_title unless persons.length <= conf.person_group_length
out = ''
length = persons.length
_.each persons, (person, i) ->
out += '<a href="/about/' + person.UrlSlug + '/">' + person.FirstName + ' ' + person.Surname + '</a>'
out += '<a href="/about/' + person.UrlSlug + '/">' + person.FirstName + ' ' + (if person.Surname then person.Surname else '') + '</a>'
if i < (length - 2)
out += ', '
else if i < (length - 1)
out += ' &amp; '

out

Handlebars.registerHelper 'niceDate', (model) ->
Expand Down Expand Up @@ -100,7 +108,8 @@ define [

# build list
_.each items, (item) ->
if item.IsPortfolio and item.IsPublished

if item.IsPublished
out += '<li><a href="/portfolio/' + item.UglyHash + '/">' + item.Title + '</a></li>'
length++
out += '</ul>'
Expand All @@ -109,6 +118,15 @@ define [
title += if length > 1 then 's' else ''

return if length then "<h4>#{title}</h4>" + out else ''

Handlebars.registerHelper 'personlist', (persons) ->
out = '<ul>'

_.each persons, (person) ->
out += '<li><a href="/about/' + person.UrlSlug + '/">' + person.FirstName + ' ' + (if person.Surname then person.Surname else '') + '</a></li>'
out += '</ul>'

return "<h4>Contributors</h4>" + out

Handlebars.registerHelper 'commaSeparatedWebsites', (websites) ->
a = []
Expand Down
25 changes: 21 additions & 4 deletions app/app/modules/Portfolio.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 32 additions & 20 deletions app/app/templates/portfolio-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
<header>
<h1>{{Title}}</h1>
<p>
{{#if IsGroup}}
Group project
{{else}}
{{{nameSummary Persons}}}
{{/if}}
</p>
<p>{{niceDate this}}</p>
{{#if Websites}}
Expand All @@ -17,6 +13,34 @@ <h1>{{Title}}</h1>
{{{MarkdownedText}}}
</section>
<aside>

{{#stringCompare "Project" ClassName}}
{{#if Exhibitions}}{{{portfoliolist Exhibitions "Exhibition"}}}{{/if}}
{{#if Workshops}}{{{portfoliolist Workshops "Workshop"}}}{{/if}}
{{#if Excursions}}{{{portfoliolist Excursions "Excursion"}}}{{/if}}
{{#if combinedProjects}}{{{portfoliolist combinedProjects "Project"}}}{{/if}}
{{/stringCompare}}

{{#stringCompare "Exhibition" ClassName}}
{{#if combinedProjects}}{{{portfoliolist combinedProjects "Project"}}}{{/if}}
{{#if Workshops}}{{{portfoliolist Workshops "Workshop"}}}{{/if}}
{{#if Excursions}}{{{portfoliolist Excursions "Excursion"}}}{{/if}}
{{/stringCompare}}

{{#stringCompare "Excursion" ClassName}}
{{#if Exhibitions}}{{{portfoliolist Exhibitions "Exhibition"}}}{{/if}}
{{#if Workshops}}{{{portfoliolist Workshops "Workshop"}}}{{/if}}
{{#if combinedProjects}}{{{portfoliolist combinedProjects "Project"}}}{{/if}}
{{/stringCompare}}

{{#stringCompare "Workshop" ClassName}}
{{#if Exhibitions}}{{{portfoliolist Exhibitions "Exhibition"}}}{{/if}}
{{#if Excursions}}{{{portfoliolist Excursions "Excursion"}}}{{/if}}
{{#if combinedProjects}}{{{portfoliolist combinedProjects "Project"}}}{{/if}}
{{/stringCompare}}

<hr/>

{{#if Categories}}
<h4>Categories</h4>
<ul>
Expand All @@ -26,31 +50,19 @@ <h4>Categories</h4>
</ul>
{{/if}}

{{#if combinedProjects}}
{{{portfoliolist combinedProjects "Project"}}}
{{/if}}

{{#if Exhibitions}}
{{{portfoliolist Exhibitions "Exhibition"}}}
{{/if}}

{{#if Workshops}}
{{{portfoliolist Workshops "Workshop"}}}
{{/if}}

{{#if Excursions}}
{{{portfoliolist Excursions "Excursion"}}}
{{#if IsGroup}}
{{{personlist Persons}}}
{{/if}}
</aside>

{{#if Code}}
<!--{{#if Code}}
<script type="text/javascript">
$(document).one('code:kickoff', function (e) {
{{{Code}}}
e.stopImmediatePropagation();
});
</script>
{{/if}}
{{/if}}-->

<!-- /article -->
3 changes: 2 additions & 1 deletion nm/code/dataobjects/CalendarEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class CalendarEntry extends DataObject {
'Workshops' => 'Workshop', // Workshops
'Excursions' => 'Excursion', // Exkursionen
'Projects' => 'Project', // Projekte
'Exhibitions' => 'Exhibition' // Ausstellungen
'Exhibitions' => 'Exhibition', // Ausstellungen
'Images' => 'DocImage'
);


Expand Down
9 changes: 5 additions & 4 deletions nm/code/dataobjects/DocImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
class DocImage extends SubdomainResponsiveImage {

private static $belongs_many_many = array(
'Excursions' => 'Excursion', // Exkursionen
'Exhibitions' => 'Exhibition', // Ausstellungen
'Projects' => 'Project', // Projekte
'Workshops' => 'Workshop' // Workshops
'Excursions' => 'Excursion', // Exkursionen
'Exhibitions' => 'Exhibition', // Ausstellungen
'Projects' => 'Project', // Projekte
'Workshops' => 'Workshop', // Workshops
'CalendarEntries' => 'CalendarEntry'
);

private static $singular_name = 'Image';
Expand Down
2 changes: 1 addition & 1 deletion nm/code/extensions/Markdown/ResponsiveImageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function formatMarkdown($mdText, $callee = null) {
if ($imgID) {

$img = DataObject::get_by_id(self::$img_class, (int) $imgID);
if ($img && $img->exists() && $callee && $callee->Images()->byID($img->ID)) {
if ($img && $img->exists() && $callee && $callee->hasMethod('Images') && $callee->Images()->byID($img->ID)) {

// 3.) add possible extra classes
foreach ($tmpArray as $extraClass) {
Expand Down

0 comments on commit 15361db

Please sign in to comment.