1
0

Added custom Blogposts for ProblemEulerBefunge

This commit is contained in:
2014-09-28 02:37:53 +02:00
parent 144ded4750
commit 58eb50f0ad
31 changed files with 1314 additions and 50 deletions

View File

@@ -30,6 +30,8 @@
<?php echo $form->textAreaControlGroup($model,'Content',array('rows'=>30,'span'=>8)); ?>
<?php echo $form->textFieldControlGroup($model,'ControllerID',array('span'=>8)); ?>
<?php
if ($model->isNewRecord)
echo $form->textFieldControlGroup($model,'Visible',array('span'=>5, 'value' => '1'));

View File

@@ -17,6 +17,8 @@
<?php echo $form->textAreaControlGroup($model,'Content',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textFieldControlGroup($model,'ControllerID',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'Visible',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'Enabled',array('span'=>5)); ?>

View File

@@ -21,6 +21,11 @@
<?php echo CHtml::encode($data->Content); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('ControllerID')); ?>:</b>
<?php echo CHtml::encode($data->ControllerID); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('Visible')); ?>:</b>
<?php echo CHtml::encode($data->Visible); ?>
<br />

View File

@@ -0,0 +1,168 @@
<?php
/* @var $this BlogPostController */
/* @var $model BlogPost */
/* @var $problems EulerProblem[] */
/* @var $currproblemID int */
/* @var $currproblem EulerProblem */
?>
<?php
$this->pageTitle = 'Blogpost: ' . $model->Title . ' - ' . Yii::app()->name;
if ($currproblemID < 0)
{
$this->breadcrumbs = array(
'Blog' => ['/blog'],
$model->Title,
);
}
else
{
$this->breadcrumbs = array(
'Blog' => ['/blog'],
$model->Title => [$model->getLink()],
'Problem_' . str_pad($problems[$currproblemID]->Problemnumber, 3, '0', STR_PAD_LEFT),
);
}
array_push($this->css_files, "/css/blogpost_ProjectEulerBefunge_style.css");
?>
<div class="container">
<?php echo MsHtml::pageHeader("Blog", "My personal programming blog"); ?>
<?php if ($currproblemID < 0): ?>
<div class="blogOwner well markdownOwner" style="position: relative;">
<a href="https://github.com/Mikescher/Project-Euler_Befunge"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<h1><?php echo $model->Title ?></h1>
<p><a href="https://projecteuler.net/problems"><img src="http://projecteuler.net/profile/Mikescher.png" /></a></p>
<p>A lot of you probably know <a href="https://projecteuler.net/">Project Euler</a>.<br />
For those who don't here a short explanation: Project Euler is a collection of mathematical/programming problems.
Most problems consist of finding a single number and are solved by writing a program in the programming language of your choice.</p>
<p>Most people solve these by using normal languages like C, Java, Phyton, Haskell etc.
But you can also go a step further and try solving it with a little bit more exotic languages.</p>
<p>So here are my solutions written in <a href="http://esolangs.org/wiki/Befunge">Befunge</a></p>
<blockquote>
<p><strong>Note:</strong><br />
Similar to most Befunge content on this site I only used the Befunge-93 instruction-set but ignored the 80x25 size restriction.
<em>(Even so most programs here don't get this big.)</em></p>
</blockquote>
<table class="PEB_tableProblems items table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Number</th>
<th>Title</th>
<th>Time</th>
<th>Size</th>
<th>Solution (hover to reveal)</th>
</tr>
</thead>
<tbody>
<?php
for($i = 0; $i < count($problems); $i++)
{
$problem = $problems[$i];
echo '<tr class="PEB_tablerowProblems">' . "\r\n";
echo '<td class="PEB_tablecellProblems PEB_TC_Number">' . $problem->Problemnumber . "</td>\r\n";
echo '<td class="PEB_tablecellProblems PEB_TC_Title"><a href="?problem=' . $problems[$i]->Problemnumber . '">' . $problem->Problemtitle . "</a></td>\r\n";
echo '<td class="PEB_tablecellProblems"><div class="PEB_TC_Time PEB_TC_Timelevel_' . $problem->getTimeScore() . '">' . MsHelper::formatMilliseconds($problem->SolutionTime) . "</div></td>\r\n";
if ($problem->isBefunge93())
echo '<td class="PEB_tablecellProblems">' . $problem->SolutionWidth . 'x' . $problem->SolutionHeight . '<div class="PEB_TC_Size_93">Bef-93</div>' . "</td>\r\n";
else
echo '<td class="PEB_tablecellProblems">' . $problem->SolutionWidth . 'x' . $problem->SolutionHeight . '<div class="PEB_TC_Size_98">Bef-98</div>' . "</td>\r\n";
echo '<td class="PEB_tablecellProblems PEB_TC_Value">' . number_format($problem->SolutionValue, 0, null, ',') . "</td>\r\n";
echo "</tr>\r\n";
}
?>
</tbody>
</table>
</div>
<?php endif ?>
<div class="blogOwner well markdownOwner" style="position: relative;">
<?php
if ($currproblemID >= 0)
{
echo '<a href="https://github.com/Mikescher/Project-Euler_Befunge"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>';
echo "<h1>$model->Title</h1>";
echo ParsedownHelper::parse($currproblem->generateMarkdown());
}
else
{
echo "<h2>Problems:</h2>";
}
?>
<?php
$pagination = array();
for ($i = 0; $i < ceil(count($problems)/20)*20; $i++)
{
if ($i < count($problems))
array_push($pagination,
[
'label' => str_pad($problems[$i]->Problemnumber, 3, '0', STR_PAD_LEFT),
'url' => '?problem=' . $problems[$i]->Problemnumber,
'disabled' => false,
'active' => $currproblemID == $i,
]);
else
array_push($pagination,
[
'label' => str_pad($i+1, 3, '0', STR_PAD_LEFT),
'url' => '#',
'disabled' => true,
'active' => false,
]);
if ((($i+1) % 20 == 0))
{
echo TbHtml::pagination($pagination, ['align' => TbHtml::PAGINATION_ALIGN_CENTER]);
$pagination = array();
}
}
echo TbHtml::pagination($pagination, ['align' => TbHtml::PAGINATION_ALIGN_CENTER]);
?>
<div class="blogFooter">
<div class="blogFooterLeft">
<?php echo $model->Title; ?>
</div>
<div class="blogFooterRight">
<?php echo $model->getDateTime()->format('d.m.Y'); ?>
</div>
</div>
</div>
<div class="disqus_owner">
<?php
$this->widget(
'ext.YiiDisqusWidget.YiiDisqusWidget',
[
'shortname' => 'mikescher-de',
'identifier' => 'blog/view/' + $model->ID,
'title' => $model->Title,
'url' => $model->getAbsoluteLink(),
'category_id' => '3253401', // = blog/view
]
);
?>
</div>
</div>

View File

@@ -0,0 +1,57 @@
<?php
/* @var $this EulerProblemController */
/* @var $model EulerProblem */
/* @var $form TbActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'euler-problem-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textFieldControlGroup($model,'Problemnumber',array('span'=>8)); ?>
<?php echo $form->textFieldControlGroup($model,'Problemtitle',array('span'=>5,'maxlength'=>50)); ?>
<?php echo $form->textAreaControlGroup($model,'Problemdescription',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textAreaControlGroup($model,'Code',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textAreaControlGroup($model,'Explanation',array('rows'=>6,'span'=>8)); ?>
<?php
if ($model->isNewRecord)
echo $form->textFieldControlGroup($model,'AbbreviatedCode',array('span'=>5, 'value' => '0'));
else
echo $form->textFieldControlGroup($model,'AbbreviatedCode',array('span'=>5));
?>
<?php echo $form->textFieldControlGroup($model,'SolutionSteps',array('span'=>5,'maxlength'=>20)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionTime',array('span'=>5,'maxlength'=>20)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionWidth',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionHeight',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionValue',array('span'=>5,'maxlength'=>20)); ?>
<div class="form-actions">
<?php echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
'size'=>TbHtml::BUTTON_SIZE_LARGE,
)); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->

View File

@@ -0,0 +1,41 @@
<?php
/* @var $this EulerProblemController */
/* @var $model EulerProblem */
/* @var $form CActiveForm */
?>
<div class="wide form">
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<?php echo $form->textFieldControlGroup($model,'Problemnumber',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'Problemtitle',array('span'=>5,'maxlength'=>50)); ?>
<?php echo $form->textAreaControlGroup($model,'Problemdescription',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textAreaControlGroup($model,'Code',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textAreaControlGroup($model,'Explanation',array('rows'=>6,'span'=>8)); ?>
<?php echo $form->textFieldControlGroup($model,'AbbreviatedCode',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionSteps',array('span'=>5,'maxlength'=>20)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionTime',array('span'=>5,'maxlength'=>20)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionWidth',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionHeight',array('span'=>5)); ?>
<?php echo $form->textFieldControlGroup($model,'SolutionValue',array('span'=>5,'maxlength'=>20)); ?>
<div class="form-actions">
<?php echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY,));?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->

View File

@@ -0,0 +1,55 @@
<?php
/* @var $this EulerProblemController */
/* @var $data EulerProblem */
?>
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('Problemnumber')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->Problemnumber),array('view','id'=>$data->Problemnumber)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('Problemtitle')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->Problemtitle)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('Problemdescription')); ?>:</b>
<?php echo CHtml::encode($data->Problemdescription); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('Code')); ?>:</b>
<?php echo CHtml::encode($data->Code); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('Explanation')); ?>:</b>
<?php echo CHtml::encode($data->Explanation); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('AbbreviatedCode')); ?>:</b>
<?php echo CHtml::encode($data->AbbreviatedCode); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('SolutionSteps')); ?>:</b>
<?php echo CHtml::encode($data->SolutionSteps); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('SolutionWidth')); ?>:</b>
<?php echo CHtml::encode($data->SolutionTime); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('SolutionHeight')); ?>:</b>
<?php echo CHtml::encode($data->SolutionTime); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('SolutionTime')); ?>:</b>
<?php echo CHtml::encode($data->SolutionTime); ?>
<br />
<?php /*
<b><?php echo CHtml::encode($data->getAttributeLabel('SolutionValue')); ?>:</b>
<?php echo CHtml::encode($data->SolutionValue); ?>
<br />
*/ ?>
</div>

View File

@@ -0,0 +1,64 @@
<?php
/* @var $this EulerProblemController */
/* @var $model EulerProblem */
$this->breadcrumbs=array(
'Euler Problems'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List EulerProblem', 'url'=>array('index')),
array('label'=>'Create EulerProblem', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#euler-problem-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manage Euler Problems</h1>
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>
&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button btn')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'id'=>'euler-problem-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'Problemnumber',
'Problemdescription',
'Code',
'Explanation',
'AbbreviatedCode',
'SolutionSteps',
/*
'SolutionTime',
'SolutionValue',
*/
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),
)); ?>

View File

@@ -0,0 +1,20 @@
<?php
/* @var $this EulerProblemController */
/* @var $model EulerProblem */
?>
<?php
$this->breadcrumbs=array(
'Euler Problems'=>array('index'),
'Create',
);
$this->menu=array(
array('label'=>'List EulerProblem', 'url'=>array('index')),
array('label'=>'Manage EulerProblem', 'url'=>array('admin')),
);
?>
<h1>Create EulerProblem</h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@@ -0,0 +1,35 @@
<?php
/* @var $this EulerProblemController */
/* @var $dataProvider CActiveDataProvider */
?>
<?php
$this->breadcrumbs=array(
'Euler Problems',
);
$this->menu=array(
array('label'=>'Create EulerProblem','url'=>array('create')),
array('label'=>'Manage EulerProblem','url'=>array('admin')),
);
?>
<h1>Euler Problems</h1>
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'type'=>'striped bordered condensed',
'dataProvider'=>$dataProvider,
'columns'=>array(
'Problemnumber',
'Problemtitle',
'Problemdescription',
'AbbreviatedCode',
'SolutionWidth',
'SolutionHeight',
'SolutionSteps',
'SolutionTime',
'SolutionValue',
),
)); ?>

View File

@@ -0,0 +1,23 @@
<?php
/* @var $this EulerProblemController */
/* @var $model EulerProblem */
?>
<?php
$this->breadcrumbs=array(
'Euler Problems'=>array('index'),
'#' . $model->Problemnumber=>array('view','id'=>$model->Problemnumber),
'Update',
);
$this->menu=array(
array('label'=>'List EulerProblem', 'url'=>array('index')),
array('label'=>'Create EulerProblem', 'url'=>array('create')),
array('label'=>'View EulerProblem', 'url'=>array('view', 'id'=>$model->Problemnumber)),
array('label'=>'Manage EulerProblem', 'url'=>array('admin')),
);
?>
<h1>Update EulerProblem <?php echo $model->Problemnumber; ?></h1>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>

View File

@@ -0,0 +1,38 @@
<?php
/* @var $this EulerProblemController */
/* @var $model EulerProblem */
?>
<?php
$this->breadcrumbs=array(
'Euler Problems'=>array('index'),
'#' . $model->Problemnumber,
);
$this->menu=array(
array('label'=>'List EulerProblem', 'url'=>array('index')),
array('label'=>'Create EulerProblem', 'url'=>array('create')),
array('label'=>'Update EulerProblem', 'url'=>array('update', 'id'=>$model->Problemnumber)),
array('label'=>'Delete EulerProblem', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->Problemnumber),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage EulerProblem', 'url'=>array('admin')),
);
?>
<h1>View EulerProblem #<?php echo $model->Problemnumber; ?></h1>
<?php $this->widget('zii.widgets.CDetailView',array(
'htmlOptions' => array(
'class' => 'table table-striped table-condensed table-hover',
),
'data'=>$model,
'attributes'=>array(
'Problemnumber',
'Problemdescription',
'Code',
'Explanation',
'AbbreviatedCode',
'SolutionSteps',
'SolutionTime',
'SolutionValue',
),
)); ?>

View File

@@ -19,9 +19,13 @@
<link rel="icon" type="image/png" href="/images/favicon.png"/>
<?php Yii::app()->bootstrap->register(); ?>
<link rel="stylesheet" type="text/css" href="/css/styles.css"/>
<link rel="stylesheet" type="text/css" href="/css/prism.css"/>
<link rel="stylesheet" type="text/css" href="/css/lightbox.css"/>
<?php
foreach ($this->css_files as $file)
{
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$file\"/>\r\n";
}
?>
</head>
<body>
<!--if lt IE 7]>

View File

@@ -48,7 +48,6 @@ $this->breadcrumbs =
echo MsHtml::stackedTabs(
[
['label' => 'Show', 'url' => '/programupdates'],
['label' => 'Manage', 'url' => '/programupdates/admin'],
['label' => 'Create', 'url' => '/programupdates/create'],
]
@@ -69,6 +68,59 @@ $this->breadcrumbs =
</div>
</div>
<div class="row">
<div class="span3">
<?php
echo MsHtml::lead('EulerProblems');
echo MsHtml::stackedTabs(
[
['label' => 'Manage', 'url' => '/eulerproblem/admin'],
['label' => 'Create', 'url' => '/eulerproblem/create'],
]
); ?>
</div>
<div class="span3" style="visibility: hidden">
<?php
echo MsHtml::lead('xxx');
echo MsHtml::stackedTabs(
[
['label' => 'Show', 'url' => '/xxx'],
['label' => 'Manage', 'url' => '/xxx/admin'],
['label' => 'Create', 'url' => '/xxx/create'],
]
); ?>
</div>
<div class="span3" style="visibility: hidden">
<?php
echo MsHtml::lead('xxx');
echo MsHtml::stackedTabs(
[
['label' => 'Show', 'url' => '/xxx'],
['label' => 'Manage', 'url' => '/xxx/admin'],
['label' => 'Create', 'url' => '/xxx/create'],
]
); ?>
</div>
<div class="span3" style="visibility: hidden">
<?php
echo MsHtml::lead('xxx');
echo MsHtml::stackedTabs(
[
['label' => 'Show', 'url' => '/xxx'],
['label' => 'Manage', 'url' => '/xxx/admin'],
['label' => 'Create', 'url' => '/xxx/create'],
]
); ?>
</div>
</div>
<div class="well well-small">
<?php
$egh = $egh = (new ExtendedGitGraph('Mikescher'))->loadFinishedData();

View File

@@ -23,9 +23,18 @@ $this->selectedNav = 'prog';
<?php
if (empty($category))
{
echo MsHtml::pageHeader("Programs", "Games and Tools, developed by me");
}
else
{
echo MsHtml::pageHeader("Programs", '"' . $category . '"');
$this->breadcrumbs = array(
'Programs' => '/programs',
$category
);
}
?>
<div class="row-fluid">

View File

@@ -11,6 +11,9 @@ $this->breadcrumbs = array(
'Programs' => array('index'),
$model->Name,
);
array_push($this->css_files, "/css/lightbox.css");
?>
<?php
@@ -112,7 +115,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
'color' => TbHtml::BUTTON_COLOR_PRIMARY,
'size' => TbHtml::BUTTON_SIZE_DEFAULT,
'Content' => 'nofollow',
'url' => $model->getDownloadLink(), //TODO-MS Add Download link
'url' => $model->getDownloadLink(),
]);
?>
@@ -156,7 +159,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
'block' => true,
'color' => TbHtml::BUTTON_COLOR_SUCCESS,
'size' => TbHtml::BUTTON_SIZE_DEFAULT,
'url' => '/Highscores/list?gameid=' . $model->highscore_gid, //TODO-MS Add Highscore link
'url' => '/Highscores/list?gameid=' . $model->highscore_gid,
]);
?>
</div>