Skip to content

Commit 0cbc73a

Browse files
authored
Merge pull request #546 from topcoder-platform/issues-519_2
Issues-519: made service files executable
2 parents 0676c94 + fb287d2 commit 0cbc73a

File tree

8 files changed

+105
-13
lines changed

8 files changed

+105
-13
lines changed

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,9 @@ RUN echo 'deb https://packages.tideways.com/apt-packages debian main' > /etc/apt
8888
# Copy custom supervisor's configs and scripts
8989
# Netcat is used to connect to a memcached server
9090
RUN apt-get update && apt-get install -y netcat
91-
COPY ./services /opt/docker/etc/supervisor.d/
92-
COPY ./services /opt/docker/bin/service.d/
91+
COPY ./services/*.conf /opt/docker/etc/supervisor.d/
92+
COPY ./services/*.sh /opt/docker/bin/service.d/
93+
94+
# Ensure the service files are already executable
95+
RUN chmod +x /opt/docker/bin/service.d/flush_cache.sh
96+
RUN chmod +x /opt/docker/bin/service.d/tideways.sh

services/tideways.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ priority=10
66
command=/opt/docker/bin/service.d/tideways.sh
77
process_name=%(program_name)s
88
startsecs=0
9-
startretries=0
9+
startretries=3
1010
autostart=true
11-
autorestart=false
11+
autorestart=true
1212
stdout_logfile=/dev/stdout
1313
stdout_logfile_maxbytes=0
1414
stderr_logfile=/dev/stderr

vanilla/applications/vanilla/controllers/class.categoriescontroller.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,21 @@ private function getCategoryTree($category = null, $displayAs = null, $recent =
150150
case 'Default':
151151
case 'Nested':
152152
default:
153-
$categoryTree = $this->CategoryModel
154-
->setJoinUserCategory(true)
155-
->getChildTree(
156-
$categoryIdentifier ?: null,
157-
['depth' => CategoryModel::instance()->getMaxDisplayDepth() ?: 10]
158-
);
153+
// FIX: https://github.com/topcoder-platform/forums/issues/487
154+
if( $categoryIdentifier != -1 && $categoryIdentifier != null) {
155+
$categoryTree = $this->CategoryModel
156+
->setJoinUserCategory(true)
157+
->getChildTree(
158+
$categoryIdentifier,
159+
['depth' => CategoryModel::instance()->getMaxDisplayDepth() ?: 10]
160+
);
161+
} else {
162+
$categoryTree = $this->CategoryModel
163+
->setJoinUserCategory(true)
164+
->getChildTree(-1, ['maxdepth' => 3,
165+
'collapsecategories' => false,
166+
'permission' => 'PermsDiscussionsView']);
167+
}
159168
}
160169

161170
if ($recent) {
@@ -293,6 +302,9 @@ public function index($categoryIdentifier = '', $page = '0') {
293302
$this->setData('CategorySort', $sort);
294303

295304
if ($categoryIdentifier == '') {
305+
// Add jquery-accordion ui
306+
$this->addJsFile('jquery-ui-1.10.0.custom.min.js');
307+
$this->addJsFile('home.js');
296308
$this->fireEvent('EnableFollowingFilter', [
297309
'CategoryIdentifier' => $categoryIdentifier,
298310
'EnableFollowingFilter' => &$this->enableFollowingFilter

vanilla/applications/vanilla/controllers/class.discussioncontroller.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ public function index($DiscussionID = '', $DiscussionStub = '', $Page = '') {
125125
Gdn_Theme::section($CategoryCssClass);
126126
}
127127

128-
$this->setData('Breadcrumbs', $this->buildBreadcrumbs($this->CategoryID));
128+
$ancestors = $this->buildBreadcrumbs($this->CategoryID);
129+
array_push($ancestors, ['Name' => $this->Discussion->Name]);
130+
131+
$this->setData('Breadcrumbs', $ancestors);
129132

130133
// Setup
131134
$this->title($this->Discussion->Name);

vanilla/applications/vanilla/controllers/class.vanillacontroller.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ protected function buildBreadcrumbs($CategoryID) {
102102
}
103103
}
104104

105-
array_unshift($ancestors, self::ROOT_CATEGORY);
106105
return $ancestors;
107106
}
108107
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
jQuery(document).ready(function($) {
2+
$(".CategoryAccordion").accordion({ header: ".CategoryAccordionHeader",
3+
animate:false,
4+
collapsible: true,
5+
active: 0, heightStyle: "content" ,
6+
icons: { "header": "icon icon-chevron-down", "activeHeader": "icon icon-chevron-up" }});
7+
8+
});

vanilla/applications/vanilla/views/categories/all.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@
1919
}
2020
echo '</div>';
2121
$categories = $this->data('CategoryTree');
22-
writeCategoryList($categories, 1);
22+
if(!is_null($this->Category)) {
23+
writeCategoryList($categories, 1);
24+
} else {
25+
writeCategoryAccordion($categories, 1);
26+
}

vanilla/applications/vanilla/views/categories/helper_functions.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,68 @@ function writeTableRow($row, $depth = 1) {
363363
}
364364
endif;
365365

366+
if (!function_exists('writeCategoryAccordion')):
367+
/**
368+
* Renders a category list (modern view).
369+
*
370+
* @param $categories
371+
* @param int $depth
372+
*/
373+
function writeCategoryAccordion($categories, $depth = 1) {
374+
if (empty($categories)) {
375+
echo '<div class="Empty">'.t('No categories were found.').'</div>';
376+
return;
377+
}
378+
379+
?>
380+
<div class="DataListWrap DataAccordionWrap">
381+
<div id="CategoryAccordion" class="CategoryAccordion">
382+
<?php
383+
foreach ($categories as $category) {
384+
writeAccordionItem($category, $depth);
385+
}
386+
?>
387+
</div>
388+
</div>
389+
<?php
390+
}
391+
endif;
392+
393+
if (!function_exists('writeAccordionItem')):
394+
/**
395+
* Renders a accordion item in a category list (modern view).
396+
*
397+
* @param $category
398+
* @param $depth
399+
* @throws Exception
400+
*/
401+
function writeAccordionItem($category, $depth) {
402+
$urlcode = $category['UrlCode'];
403+
// FIX: https://github.com/topcoder-platform/forums/issues/477: Don't show 'Challenge Forums'
404+
if($urlcode == VanillaController::CHALLENGE_FORUMS_URLCODE) {
405+
return;
406+
}
407+
$children = val('Children',$category);
408+
$categoryID = val('CategoryID', $category);
409+
$cssClass = cssClass($category, true);
410+
?>
411+
<div id="Category_<?php echo $categoryID; ?>" class="CategoryAccordionItem">
412+
<div class="<?php echo $cssClass; ?> CategoryAccordionHeader">
413+
<a class="toggle" href="javascript:void(0);"><?php echo Gdn_Format::text(val('Name', $category)); ?></a>
414+
</div>
415+
<ul id="Category_<?php echo $categoryID; ?>_child" class="DataList CategoryList CategoryAccordionCollapse">
416+
<?php
417+
foreach ($children as $child) {
418+
writeListItem($child, $depth + 1);
419+
}
420+
?>
421+
</ul>
422+
</div>
423+
424+
<?php
425+
}
426+
endif;
427+
366428
if (!function_exists('writeCategoryList')):
367429
/**
368430
* Renders a category list (modern view).

0 commit comments

Comments
 (0)