Skip to content

Commit

Permalink
v.1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
findlabnet committed Oct 9, 2016
1 parent 8977a0a commit d08935b
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 112 deletions.
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
Easy XML sitemap
===================================

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

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

- pages created by nodes
- non-empty taxonomy terms pages
- public available pages by "Views" module
- pages created by nodes;
- non-empty taxonomy terms pages;
- publicly available pages by "Views" module.

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

For URLs which you do not want include to sitemap, exclusions may be added.
URLs which you do not want include to sitemap may be excluded.

Content which presented on any of available languages can be excluded from the sitemap.

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

Optional and less important URLs attributes "priority" and "lastmod"
are omitted in this version.
Less important and optional URLs attributes "priority" and "lastmod" are omitted in this version.

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

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

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

License
-------

This project is GPL v2 software. See the LICENSE.txt file in this directory for
complete text.

Current Maintainer
------------------

Vladimir (https://github.com/findlabnet/)

More information
----------------
For bug reports, feature or support requests, please use the module
issue queue at https://github.com/backdrop-contrib/easy_xmlsitemap/issues.
3 changes: 2 additions & 1 deletion config/easy_xmlsitemap.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"sitemap_dir": "easy_xmlsitemap",
"rebuild_frequency": "daily",
"last_build_date": 0,
"excluded_urls": ""
"excluded_urls": "",
"excluded_langs": []
}
48 changes: 29 additions & 19 deletions easy_xmlsitemap.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,50 @@
*
*/
function easy_xmlsitemap_settings_form() {

$config = config('easy_xmlsitemap.settings');
$config = config('easy_xmlsitemap.settings');
$last_build_date = $config->get('last_build_date');

$info = $last_build_date != 0
? t('Sitemap file last build time: ') . format_date($last_build_date, 'short')
: t('Sitemap file has not built yet.');
? t('Sitemap last build time: ') . format_date($last_build_date, 'short')
: t('Sitemap has not built yet.');

$site_langs = language_list(TRUE, TRUE);

$form = array();

$form['build_info'] = array(
'#type' => 'fieldset',
'#title' => t('Sitemap build'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
);

$form['build_info']['info'] = array(
'#markup' => '<p>' . $info . '</p>',
);
$form['build_info']['actions'] = array('#type' => 'actions');
$form['build_info']['actions']['build'] = array(
$form['build_info']['build'] = array(
'#type' => 'submit',
'#value' => t('Build sitemap now'),
'#attributes' => array(
'class' => array('button-primary'),
),
);
$form['build_info']['actions']['info'] = array(
'#markup' => '<div class="description">' . t('This will rebuild XML sitemap.') . '</div>',
'#markup' => '<div class="description">' . t('This will rebuild sitemap immediately.') . '</div>',
);

$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);

$form['settings']['base_url'] = array(
'#type' => 'textfield',
'#title' => t('Default base URL'),
'#title' => t('Default base URL (optional)'),
'#default_value' => $config->get('base_url'),
'#description' => t('Optional default base URL used for sitemaps and sitemap links, for example: http://example.com, can be left empty.'),
'#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.'),
);
$form['settings']['rebuild_frequency'] = array(
'#type' => 'select',
Expand All @@ -68,37 +71,45 @@ function easy_xmlsitemap_settings_form() {
'#type' => 'textarea',
'#title' => t('Excluded URLs list (optional)'),
'#default_value' => $config->get('excluded_urls'),
'#description' => t('If some URLs should be excluded from sitemap, place these URLs here, one URL per line without domain, for example:')
'#description' => t('If some URLs should be excluded from sitemap, place these URLs here, one URL per line without domain, see an example below:')
. '<br />403.html'
. '<br />404.html'
. '<br />node/123'
. '<br />some-test-page.html'
);

$form['settings']['actions'] = array('#type' => 'actions');
$form['settings']['actions']['submit'] = array(
if (count($site_langs) > 1) {
$form['settings']['excluded_langs'] = array(
'#type' => 'checkboxes',
'#title' => t('Exclude from sitemap all pages for selected language (optional):'),
'#options' => $site_langs,
'#default_value' => $config->get('excluded_langs'),
'#description' => t('In some cases you might want do not include to sitemap links to pages for specific language.'),
);
}
$form['settings']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
'#attributes' => array(
'class' => array('button-primary'),
),
);

return $form;

}

/**
* Submit actions for form
*
*/
function easy_xmlsitemap_settings_form_submit($form, &$form_state) {

global $user;
$config = config('easy_xmlsitemap.settings');

if ($form_state['clicked_button']['#id'] == 'edit-submit') {

$config->set('base_url', trim($form_state['values']['base_url']));
$config->set('rebuild_frequency', $form_state['values']['rebuild_frequency']);
$config->set('excluded_urls', trim($form_state['values']['excluded_urls']));
$config->set('excluded_langs', $form_state['values']['excluded_langs']);

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

2 changes: 1 addition & 1 deletion easy_xmlsitemap.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package = SEO
backdrop = 1.x
type = module
configure = admin/config/search/easy_xmlsitemap
version = 1.0.3
version = 1.0.4

9 changes: 9 additions & 0 deletions easy_xmlsitemap.install
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ function easy_xmlsitemap_requirements($phase) {

return $requirements;
}

/**
* Add and init new empty array for excluded languages to config file.
*/
function easy_xmlsitemap_update_1000() {
$config = config('easy_xmlsitemap.settings');
$config->set('excluded_langs', array());
$config->save();
}
Loading

0 comments on commit d08935b

Please sign in to comment.