Skip to content

Commit d08935b

Browse files
committed
v.1.0.4
1 parent 8977a0a commit d08935b

File tree

6 files changed

+113
-112
lines changed

6 files changed

+113
-112
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
Easy XML sitemap
22
===================================
33

4-
Simple module for build a XML sitemap following to
5-
[Google's recommendations](https://support.google.com/webmasters/answer/2620865)
6-
for using "hreflang" attribute in sitemap of multilingual site.
4+
Generates XML sitemap conforming to [Google's recommendations](https://support.google.com/webmasters/answer/2620865)
5+
for using "hreflang" attribute in sitemap on multilingual site and [sitemaps.org protocol](http://www.sitemaps.org/protocol.html).
76

87
Features
98
--------
10-
Sitemap file will be accessible on URL *http(s)://your.domain/sitemap.xml*
11-
and automatically include URLs for:
9+
Generated sitemap is available at *http(s)://your.domain/sitemap.xml* and include URLs for:
1210

13-
- pages created by nodes
14-
- non-empty taxonomy terms pages
15-
- public available pages by "Views" module
11+
- pages created by nodes;
12+
- non-empty taxonomy terms pages;
13+
- publicly available pages by "Views" module.
1614

17-
If some node is set as site's front page, URL of this node will be
15+
If one node is set as site's front page, direct URL to this node will be
1816
automatically excluded from sitemap to avoid content duplication.
1917

20-
For URLs which you do not want include to sitemap, exclusions may be added.
18+
URLs which you do not want include to sitemap may be excluded.
19+
20+
Content which presented on any of available languages can be excluded from the sitemap.
2121

2222
Each time sitemap re-built, backup copy of previous file state is saved as
23-
public://easy_xmlsitemap/sitemap.xml.bak
23+
*public://easy_xmlsitemap/sitemap.xml.bak*
2424

25-
Optional and less important URLs attributes "priority" and "lastmod"
26-
are omitted in this version.
25+
Less important and optional URLs attributes "priority" and "lastmod" are omitted in this version.
2726

2827
Installation
2928
------------
@@ -39,23 +38,25 @@ Administration page is available via *Administration > Configuration >
3938
Search and metadata > Easy XML Sitemap* (admin/config/search/easy_xmlsitemap)
4039
and may be useful for:
4140

42-
- build XML sitemap by using button "BUILD SITEMAP NOW" (before first time build
43-
you will get error 404 from "/sitemap.xml)
44-
- get information about last time sitemap build
41+
- anytime (re)build XML sitemap by using button "BUILD SITEMAP NOW";
42+
- view information when last time sitemap was generated.
4543

46-
under "SETTINGS" fieldset:
47-
- set (if you need) different default base URL used for sitemap links
48-
- select sitemap rebuild frequency: manually, daily (default) or any cron run
49-
- add exclusions for URLs you won't include in sitemap (see description on the form).
44+
Under "Advanced settings" fieldset:
45+
- set (if you need) different default base URL used for sitemap links;
46+
- select sitemap rebuild frequency: manually, daily (default) or any cron run;
47+
- add exclusions for URLs you won't include in sitemap;
48+
- add exclusions for content of languages you won't include in sitemap.
5049

5150
License
5251
-------
53-
5452
This project is GPL v2 software. See the LICENSE.txt file in this directory for
5553
complete text.
5654

5755
Current Maintainer
5856
------------------
59-
6057
Vladimir (https://github.com/findlabnet/)
6158

59+
More information
60+
----------------
61+
For bug reports, feature or support requests, please use the module
62+
issue queue at https://github.com/backdrop-contrib/easy_xmlsitemap/issues.

config/easy_xmlsitemap.settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"sitemap_dir": "easy_xmlsitemap",
55
"rebuild_frequency": "daily",
66
"last_build_date": 0,
7-
"excluded_urls": ""
7+
"excluded_urls": "",
8+
"excluded_langs": []
89
}

easy_xmlsitemap.admin.inc

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,50 @@
1111
*
1212
*/
1313
function easy_xmlsitemap_settings_form() {
14-
15-
$config = config('easy_xmlsitemap.settings');
14+
$config = config('easy_xmlsitemap.settings');
1615
$last_build_date = $config->get('last_build_date');
1716

1817
$info = $last_build_date != 0
19-
? t('Sitemap file last build time: ') . format_date($last_build_date, 'short')
20-
: t('Sitemap file has not built yet.');
18+
? t('Sitemap last build time: ') . format_date($last_build_date, 'short')
19+
: t('Sitemap has not built yet.');
2120

21+
$site_langs = language_list(TRUE, TRUE);
22+
2223
$form = array();
2324

2425
$form['build_info'] = array(
2526
'#type' => 'fieldset',
2627
'#title' => t('Sitemap build'),
2728
'#collapsible' => TRUE,
2829
'#collapsed' => FALSE,
29-
);
30+
);
3031

3132
$form['build_info']['info'] = array(
3233
'#markup' => '<p>' . $info . '</p>',
3334
);
34-
$form['build_info']['actions'] = array('#type' => 'actions');
35-
$form['build_info']['actions']['build'] = array(
35+
$form['build_info']['build'] = array(
3636
'#type' => 'submit',
3737
'#value' => t('Build sitemap now'),
38+
'#attributes' => array(
39+
'class' => array('button-primary'),
40+
),
3841
);
3942
$form['build_info']['actions']['info'] = array(
40-
'#markup' => '<div class="description">' . t('This will rebuild XML sitemap.') . '</div>',
43+
'#markup' => '<div class="description">' . t('This will rebuild sitemap immediately.') . '</div>',
4144
);
4245

4346
$form['settings'] = array(
4447
'#type' => 'fieldset',
45-
'#title' => t('Settings'),
48+
'#title' => t('Advanced settings'),
4649
'#collapsible' => TRUE,
4750
'#collapsed' => TRUE,
4851
);
4952

5053
$form['settings']['base_url'] = array(
5154
'#type' => 'textfield',
52-
'#title' => t('Default base URL'),
55+
'#title' => t('Default base URL (optional)'),
5356
'#default_value' => $config->get('base_url'),
54-
'#description' => t('Optional default base URL used for sitemaps and sitemap links, for example: http://example.com, can be left empty.'),
57+
'#description' => t('Optional replacement for base URL, should be used instead of actual domain for sitemap links, for example: http://example.com. In most cases can be left empty.'),
5558
);
5659
$form['settings']['rebuild_frequency'] = array(
5760
'#type' => 'select',
@@ -68,37 +71,45 @@ function easy_xmlsitemap_settings_form() {
6871
'#type' => 'textarea',
6972
'#title' => t('Excluded URLs list (optional)'),
7073
'#default_value' => $config->get('excluded_urls'),
71-
'#description' => t('If some URLs should be excluded from sitemap, place these URLs here, one URL per line without domain, for example:')
74+
'#description' => t('If some URLs should be excluded from sitemap, place these URLs here, one URL per line without domain, see an example below:')
7275
. '<br />403.html'
7376
. '<br />404.html'
7477
. '<br />node/123'
7578
. '<br />some-test-page.html'
7679
);
77-
78-
$form['settings']['actions'] = array('#type' => 'actions');
79-
$form['settings']['actions']['submit'] = array(
80+
if (count($site_langs) > 1) {
81+
$form['settings']['excluded_langs'] = array(
82+
'#type' => 'checkboxes',
83+
'#title' => t('Exclude from sitemap all pages for selected language (optional):'),
84+
'#options' => $site_langs,
85+
'#default_value' => $config->get('excluded_langs'),
86+
'#description' => t('In some cases you might want do not include to sitemap links to pages for specific language.'),
87+
);
88+
}
89+
$form['settings']['submit'] = array(
8090
'#type' => 'submit',
8191
'#value' => t('Save settings'),
92+
'#attributes' => array(
93+
'class' => array('button-primary'),
94+
),
8295
);
8396

8497
return $form;
85-
8698
}
8799

88100
/**
89101
* Submit actions for form
90102
*
91103
*/
92104
function easy_xmlsitemap_settings_form_submit($form, &$form_state) {
93-
94105
global $user;
95106
$config = config('easy_xmlsitemap.settings');
96107

97108
if ($form_state['clicked_button']['#id'] == 'edit-submit') {
98-
99109
$config->set('base_url', trim($form_state['values']['base_url']));
100110
$config->set('rebuild_frequency', $form_state['values']['rebuild_frequency']);
101111
$config->set('excluded_urls', trim($form_state['values']['excluded_urls']));
112+
$config->set('excluded_langs', $form_state['values']['excluded_langs']);
102113

103114
$config->save();
104115
watchdog('easy_xmlsitemap', t('Settings changed by @user.', array('@user' => $user->name)));
@@ -108,4 +119,3 @@ function easy_xmlsitemap_settings_form_submit($form, &$form_state) {
108119
easy_xmlsitemap_build();
109120
}
110121
}
111-

easy_xmlsitemap.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ package = SEO
44
backdrop = 1.x
55
type = module
66
configure = admin/config/search/easy_xmlsitemap
7-
version = 1.0.3
7+
version = 1.0.4
88

easy_xmlsitemap.install

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ function easy_xmlsitemap_requirements($phase) {
2727

2828
return $requirements;
2929
}
30+
31+
/**
32+
* Add and init new empty array for excluded languages to config file.
33+
*/
34+
function easy_xmlsitemap_update_1000() {
35+
$config = config('easy_xmlsitemap.settings');
36+
$config->set('excluded_langs', array());
37+
$config->save();
38+
}

0 commit comments

Comments
 (0)