Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
3fc51a92
Commit
3fc51a92
authored
Oct 19, 2015
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize theme output (minify HTML)
parent
02833d53
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
3 deletions
+20
-3
options.php
qa-include/app/options.php
+1
-0
qa-lang-options.php
qa-include/lang/qa-lang-options.php
+1
-0
admin-default.php
qa-include/pages/admin/admin-default.php
+2
-1
qa-page.php
qa-include/qa-page.php
+4
-0
qa-theme-base.php
qa-include/qa-theme-base.php
+12
-2
No files found.
qa-include/app/options.php
View file @
3fc51a92
...
...
@@ -280,6 +280,7 @@
'min_len_q_content'
=>
0
,
'min_len_q_title'
=>
12
,
'min_num_q_tags'
=>
0
,
'minify_html'
=>
1
,
'moderate_notify_admin'
=>
1
,
'moderate_points_limit'
=>
150
,
'moderate_update_time'
=>
1
,
...
...
qa-include/lang/qa-lang-options.php
View file @
3fc51a92
...
...
@@ -142,6 +142,7 @@
'min_len_q_content'
=>
'Minimum length of question body:'
,
'min_len_q_title'
=>
'Minimum length of question title:'
,
'min_num_q_tags'
=>
'Minimum number of tags:'
,
'minify_html'
=>
'Minify HTML:'
,
'moderate_anon_post'
=>
'Use moderation for anonymous posts:'
,
'moderate_by_points'
=>
'Use moderation for users with few points:'
,
'moderate_edited_again'
=>
'Re-moderate posts after editing:'
,
...
...
qa-include/pages/admin/admin-default.php
View file @
3fc51a92
...
...
@@ -219,6 +219,7 @@
'suspend_register_users'
=>
'checkbox'
,
'tag_separator_comma'
=>
'checkbox'
,
'use_microdata'
=>
'checkbox'
,
'minify_html'
=>
'checkbox'
,
'votes_separated'
=>
'checkbox'
,
'voting_on_as'
=>
'checkbox'
,
'voting_on_q_page_only'
=>
'checkbox'
,
...
...
@@ -384,7 +385,7 @@
}
array_push
(
$showoptions
,
'show_user_points'
,
'show_post_update_meta'
,
'show_compact_numbers'
,
'use_microdata'
,
''
,
'show_user_points'
,
'show_post_update_meta'
,
'show_compact_numbers'
,
'use_microdata'
,
'
minify_html'
,
'
'
,
'sort_answers_by'
,
'show_selected_first'
,
'page_size_q_as'
,
'show_a_form_immediate'
);
...
...
qa-include/qa-page.php
View file @
3fc51a92
...
...
@@ -490,6 +490,10 @@
'charset'
=>
$charset
,
'direction'
=>
qa_opt
(
'site_text_direction'
),
'options'
=>
array
(
'minify_html'
=>
qa_opt
(
'minify_html'
),
),
'site_title'
=>
qa_html
(
qa_opt
(
'site_title'
)),
'head_lines'
=>
array
(),
...
...
qa-include/qa-theme-base.php
View file @
3fc51a92
...
...
@@ -45,6 +45,7 @@ class qa_html_theme_base
public
$request
;
public
$isRTL
;
// (boolean) whether text direction is Right-To-Left
protected
$minifyHtml
;
// (boolean) whether to indent the HTML
protected
$indent
=
0
;
protected
$lines
=
0
;
protected
$context
=
array
();
...
...
@@ -65,6 +66,7 @@ class qa_html_theme_base
$this
->
rooturl
=
$rooturl
;
$this
->
request
=
$request
;
$this
->
isRTL
=
isset
(
$content
[
'direction'
])
&&
$content
[
'direction'
]
===
'rtl'
;
$this
->
minifyHtml
=
!
empty
(
$content
[
'options'
][
'minify_html'
]);
}
/**
...
...
@@ -85,17 +87,25 @@ class qa_html_theme_base
public
function
output_array
(
$elements
)
{
foreach
(
$elements
as
$element
)
{
$line
=
str_replace
(
'/>'
,
'>'
,
$element
);
if
(
$this
->
minifyHtml
)
{
if
(
strlen
(
$line
))
echo
$line
.
"
\n
"
;
}
else
{
$delta
=
substr_count
(
$element
,
'<'
)
-
substr_count
(
$element
,
'<!'
)
-
2
*
substr_count
(
$element
,
'</'
)
-
substr_count
(
$element
,
'/>'
);
if
(
$delta
<
0
)
{
$this
->
indent
+=
$delta
;
}
echo
str_repeat
(
"
\t
"
,
max
(
0
,
$this
->
indent
))
.
str_replace
(
'/>'
,
'>'
,
$element
)
.
"
\n
"
;
echo
str_repeat
(
"
\t
"
,
max
(
0
,
$this
->
indent
))
.
$line
.
"
\n
"
;
if
(
$delta
>
0
)
{
$this
->
indent
+=
$delta
;
}
}
$this
->
lines
++
;
}
...
...
@@ -201,7 +211,7 @@ class qa_html_theme_base
*/
public
function
finish
()
{
if
(
$this
->
indent
)
{
if
(
$this
->
indent
!==
0
&&
!
$this
->
minifyHtml
)
{
echo
"<!--
\n
It's no big deal, but your HTML could not be indented properly. To fix, please:
\n
"
.
"1. Use this->output() to output all HTML.
\n
"
.
"2. Balance all paired tags like <td>...</td> or <div>...</div>.
\n
"
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment