54
54
'BLOG_EMAIL' : "joe@demo.site" ,
55
55
'BLOG_DESCRIPTION' : "This is a demo site for Nikola." ,
56
56
'PRETTY_URLS' : False ,
57
+ 'STRIP_INDEXES' : False ,
57
58
'DEFAULT_LANG' : "en" ,
58
59
'TRANSLATIONS' : """{
59
60
DEFAULT_LANG: "",
103
104
'REDIRECTIONS' : [],
104
105
}
105
106
107
+
106
108
# Generate a list of supported languages here.
107
109
# Ugly code follows.
108
110
_suplang = {}
@@ -164,12 +166,12 @@ def format_default_translations_config(additional_languages):
164
166
return "{{\n {0}\n }}" .format ("\n " .join (lang_paths ))
165
167
166
168
167
- def format_navigation_links (additional_languages , default_lang , messages ):
169
+ def format_navigation_links (additional_languages , default_lang , messages , strip_indexes = False ):
168
170
"""Return the string to configure NAVIGATION_LINKS."""
169
171
f = u"""\
170
172
{0}: (
171
173
("{1}/archive.html", "{2[Archive]}"),
172
- ("{1}/categories/index.html ", "{2[Tags]}"),
174
+ ("{1}/categories/{3} ", "{2[Tags]}"),
173
175
("{1}/rss.xml", "{2[RSS feed]}"),
174
176
),"""
175
177
@@ -185,11 +187,16 @@ def get_msg(lang):
185
187
fmsg [i ] = i
186
188
return fmsg
187
189
190
+ if strip_indexes :
191
+ index_html = ''
192
+ else :
193
+ index_html = 'index.html'
194
+
188
195
# handle the default language
189
- pairs .append (f .format ('DEFAULT_LANG' , '' , get_msg (default_lang )))
196
+ pairs .append (f .format ('DEFAULT_LANG' , '' , get_msg (default_lang ), index_html ))
190
197
191
198
for l in additional_languages :
192
- pairs .append (f .format (json .dumps (l , ensure_ascii = False ), '/' + l , get_msg (l )))
199
+ pairs .append (f .format (json .dumps (l , ensure_ascii = False ), '/' + l , get_msg (l ), index_html ))
193
200
194
201
return u'{{\n {0}\n }}' .format ('\n \n ' .join (pairs ))
195
202
@@ -200,12 +207,13 @@ def prepare_config(config):
200
207
"""Parse sample config with JSON."""
201
208
p = config .copy ()
202
209
p .update (dict ((k , json .dumps (v , ensure_ascii = False )) for k , v in p .items ()
203
- if k not in ('POSTS' , 'PAGES' , 'COMPILERS' , 'TRANSLATIONS' , 'NAVIGATION_LINKS' , '_SUPPORTED_LANGUAGES' , '_SUPPORTED_COMMENT_SYSTEMS' , 'INDEX_READ_MORE_LINK' , 'RSS_READ_MORE_LINK' , 'PRETTY_URLS' )))
210
+ if k not in ('POSTS' , 'PAGES' , 'COMPILERS' , 'TRANSLATIONS' , 'NAVIGATION_LINKS' , '_SUPPORTED_LANGUAGES' , '_SUPPORTED_COMMENT_SYSTEMS' , 'INDEX_READ_MORE_LINK' , 'RSS_READ_MORE_LINK' , 'STRIP_INDEXES' , ' PRETTY_URLS' )))
204
211
# READ_MORE_LINKs require some special treatment.
205
212
p ['INDEX_READ_MORE_LINK' ] = "'" + p ['INDEX_READ_MORE_LINK' ].replace ("'" , "\\ '" ) + "'"
206
213
p ['RSS_READ_MORE_LINK' ] = "'" + p ['RSS_READ_MORE_LINK' ].replace ("'" , "\\ '" ) + "'"
207
214
# json would make that `true` instead of `True`
208
215
p ['PRETTY_URLS' ] = str (p ['PRETTY_URLS' ])
216
+ p ['STRIP_INDEXES' ] = str (p ['STRIP_INDEXES' ])
209
217
return p
210
218
211
219
@@ -296,6 +304,7 @@ def urlhandler(default, toconf):
296
304
297
305
def prettyhandler (default , toconf ):
298
306
SAMPLE_CONF ['PRETTY_URLS' ] = ask_yesno ('Enable pretty URLs (/page/ instead of /page.html) that don’t need web server configuration?' , default = True )
307
+ SAMPLE_CONF ['STRIP_INDEXES' ] = SAMPLE_CONF ['PRETTY_URLS' ]
299
308
300
309
def lhandler (default , toconf , show_header = True ):
301
310
if show_header :
@@ -333,7 +342,7 @@ def lhandler(default, toconf, show_header=True):
333
342
# not inherit from anywhere.
334
343
try :
335
344
messages = load_messages (['base' ], tr , default )
336
- SAMPLE_CONF ['NAVIGATION_LINKS' ] = format_navigation_links (langs , default , messages )
345
+ SAMPLE_CONF ['NAVIGATION_LINKS' ] = format_navigation_links (langs , default , messages , SAMPLE_CONF [ 'STRIP_INDEXES' ] )
337
346
except nikola .utils .LanguageNotFoundError as e :
338
347
print (" ERROR: the language '{0}' is not supported." .format (e .lang ))
339
348
print (" Are you sure you spelled the name correctly? Names are case-sensitive and need to be reproduced as-is (complete with the country specifier, if any)." )
0 commit comments