srchub-old

srchub-old Commit Details


Date:2014-03-12 21:30:00 (10 years 7 months ago)
Author:Natalie Adams
Branch:default
Commit:855019377dec
Parents: 0d35b479f0df
Message:Adding feature to allow users to choose a syntaxhighlighter theme per project

Changes:
Aindefero/src/IDF/Migrations/29EnableAds.php (full)
Aindefero/src/IDF/Migrations/30SyntaxHighlightTheme.php (full)
Mindefero/src/IDF/FileUtil.php (2 diffs)
Mindefero/src/IDF/Form/ProjectConf.php (3 diffs)
Mindefero/src/IDF/Project.php (1 diff)
Mindefero/src/IDF/conf/urls.php (1 diff)
Mindefero/src/IDF/templates/idf/admin/summary.html (1 diff)
Mindefero/src/IDF/templates/idf/base.html (1 diff)

File differences

indefero/src/IDF/FileUtil.php
3838
3939
4040
41
42
43
44
4145
4246
4347
......
7276
7377
7478
75
79
80
81
82
83
84
85
86
7687
7788
7889
'skin', 'sln', 'svc', 'vala', 'vb', 'vbproj', 'vbs', 'wsdl', 'xhtml',
'xml', 'xsd', 'xsl', 'xslt');
public static $map = array("h" => "cpp", "hpp" => "cpp", "rc"=>"text", "sh"=>"bash", "cs"=>"csharp");
public static $syntaxhighlightext = array("as3", "cf", "cpp", "c", "css", "pas", "diff", "patch", "erl", "java", "jfx", "js", "pl", "php", "py", "rb", "sass", "scss", "scala", "sql", "vb", );
/**
* Test if an extension is supported by the syntax highlighter.
*
}
return Pluf_Template::markSafe(implode("\n", $table));*/
//var_dump($fileinfo);
$content = '<script type="syntaxhighlighter" class="brush: ' . $fileinfo[2] . '">' . $content . '</script>';
$ext = "";
if (in_array($fileinfo[2], self::$syntaxhighlightext))
$ext = $fileinfo[2];
elseif (array_key_exists($fileinfo[2], self::$map))
$ext = self::$map[$fileinfo[2]];
else
$ext = "text";
$content = '<script type="syntaxhighlighter" class="brush: ' . $ext . '">' . $content . '</script>';
return Pluf_Template::markSafe($content);
}
indefero/src/IDF/Form/ProjectConf.php
3333
3434
3535
36
36
37
38
39
40
41
42
43
44
45
46
3747
3848
3949
......
5969
6070
6171
72
73
74
75
76
77
78
79
80
6281
6382
6483
......
208227
209228
210229
230
211231
212232
213233
{
$this->project = $extra['project'];
$this->user = $extra["user"];
$conf = $this->project->getConf();
$conf = $this->project->getConf();
$options = array(
'Default' => __('Default'),
'Django' => __('Django'),
'Eclipse' => __('Eclipse'),
'Emacs' => __('Emacs'),
'FadeToGrey' => __('FadeToGrey'),
'MDUltra' => __('MDUltra'),
'Midnight' => __('Midnight'),
'RDark' => __('RDark'),
);
// Basic part
$this->fields['name'] = new Pluf_Form_Field_Varchar(array('required' => true,
'initial' => $conf->getVal('external_project_url'),
));
$this->fields['syntaxtheme'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Syntax Highlight Theme'),
'initial' => ($this->project->syntaxtheme) ? $this->project->syntaxtheme : "Default",
'widget_attrs' => array('choices' => $options),
'widget' => 'Pluf_Form_Widget_SelectInput',
));
if ($this->user->administrator)
{
$this->fields['enableads'] = new Pluf_Form_Field_Boolean(
$this->project->shortdesc = $this->cleaned_data['shortdesc'];
$this->project->description = $this->cleaned_data['description'];
$this->project->batchAssoc('IDF_Tag', $tagids);
$this->project->syntaxtheme = $this->cleaned_data["syntaxtheme"];
if ($this->user->administrator)
$this->project->enableads = $this->cleaned_data['enableads'];
$this->project->update();
indefero/src/IDF/Migrations/29EnableAds.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
function IDF_Migrations_29EnableAds_up()
{
$table = Pluf::factory('IDF_Project')->getSqlTable();
$sql = array();
$sql["MySQL"] = "ALTER TABLE " . $table . " ADD COLUMN `enableads` int(11) NULL AFTER `current_activity`;";
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}
function IDF_Migrations_28OTPKey_down()
{
$table = Pluf::factory('IDF_Project')->getSqlTable();
$sql = array();
$sql["MySQL"] = "ALTER TABLE " . $table . " DROP COLUMN `enableads`;";
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}
indefero/src/IDF/Migrations/30SyntaxHighlightTheme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
function IDF_Migrations_30SyntaxHighlightTheme_up()
{
$table = Pluf::factory('IDF_Project')->getSqlTable();
$sql = array();
$sql["MySQL"] = "ALTER TABLE " . $table . " ADD COLUMN `syntaxtheme` VARCHAR(50) NULL AFTER `enableads`;";
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}
function IDF_Migrations_28OTPKey_down()
{
$table = Pluf::factory('IDF_Project')->getSqlTable();
$sql = array();
$sql["MySQL"] = "ALTER TABLE " . $table . " DROP COLUMN `syntaxtheme`;";
$db = Pluf::db();
$engine = Pluf::f('db_engine');
if (!isset($sql[$engine])) {
throw new Exception('SQLite complex migration not supported.');
}
$db->execute($sql[$engine]);
}
indefero/src/IDF/Project.php
116116
117117
118118
119
120
121
122
123
124
125
126
127
119128
120129
121130
'verbose' => __('enableads'),
'default' => 1,
),
'syntaxtheme' =>
array(
'type' => 'Pluf_DB_Field_Text',
'blank' => false,
'verbose' => __('syntaxtheme'),
'default' => "Default",
"size" => 50
)
);
$activityTable = $this->_con->pfx.'idf_projectactivities';
$tagTable = $this->_con->pfx.'idf_project_idf_tag_assoc';
indefero/src/IDF/conf/urls.php
2929
3030
3131
32
33
34
35
36
37
38
3239
3340
3441
'model' => 'IDF_Views',
'method' => 'index');
$ctl[] = array('regex' => '#^/u/(.*)/$#',
'base' => $base,
'model' => 'IDF_Views_User',
'method' => 'view',
'name' => 'idf_user_view');
$ctl[] = array('regex' => '#^/projects/$#',
'base' => $base,
'model' => 'IDF_Views',
indefero/src/IDF/templates/idf/admin/summary.html
7676
7777
7878
79
80
81
82
83
84
85
7986
8087
8188
<td>{if $form.f.enableads.errors}{$form.f.enableads.fieldErrors}{/if}
{$form.f.enableads|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.syntaxtheme.labelTag}:</th>
<td>{if $form.f.syntaxtheme.errors}{$form.f.syntaxtheme.fieldErrors}{/if}
{$form.f.syntaxtheme|unsafe}
</td>
</tr>
<tr><td>&nbsp;</td>
<td>
<input type="submit" name="submit" value="{trans 'Save Changes'}" />
indefero/src/IDF/templates/idf/base.html
4040
4141
4242
43
43
44
45
46
47
48
49
50
51
52
4453
4554
4655
<script type="text/javascript" src="{media '/idf/js/syntaxhighlight/shAutoloader.js'}"></script>
<link rel="stylesheet" type="text/css" href="{media '/idf/css/syntaxhighlight/shCore.css'}" />
<link rel="stylesheet" type="text/css" href="{media '/idf/css/syntaxhighlight/shCoreDefault.css'}" />
{if $project}
{if $project.syntaxtheme}
<link rel="stylesheet" type="text/css" href="{media '/idf/css/syntaxhighlight/shTheme'}{$project.syntaxtheme}.css" />
{else}
<link rel="stylesheet" type="text/css" href="{media '/idf/css/syntaxhighlight/shThemeDefault.css'}" />
{/if}
{else}
<link rel="stylesheet" type="text/css" href="{media '/idf/css/syntaxhighlight/shThemeDefault.css'}" />
{/if}
{appversion}
</head>
<body>

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.43955s using 14 queries.