small update
This commit is contained in:
16
__init__.py
16
__init__.py
@@ -6,8 +6,10 @@ from config import Config
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from os.path import isfile, abspath
|
from os.path import isfile, abspath
|
||||||
|
package_directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
cfg = Config(file('config.cfg'))
|
#cfg = Config(file('./config.cfg'))
|
||||||
|
cfg = Config(file(os.path.join(package_directory, 'config.cfg')))
|
||||||
|
|
||||||
FLATPAGES_AUTO_RELOAD = cfg.pages_reload
|
FLATPAGES_AUTO_RELOAD = cfg.pages_reload
|
||||||
FLATPAGES_EXTENSION = '.md'
|
FLATPAGES_EXTENSION = '.md'
|
||||||
@@ -15,7 +17,7 @@ FLATPAGES_ROOT = abspath(cfg.pages_root)
|
|||||||
FLATPAGES_FP_ROOT = abspath(cfg.pages_root)
|
FLATPAGES_FP_ROOT = abspath(cfg.pages_root)
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
flatpages = FlatPages(app,'FP')
|
flatpages = FlatPages(app)
|
||||||
flatpages.get('index')
|
flatpages.get('index')
|
||||||
freezer = Freezer(app)
|
freezer = Freezer(app)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
@@ -30,11 +32,19 @@ def get_sub_pages(path, page):
|
|||||||
|
|
||||||
def get_sub_ipages(path, page):
|
def get_sub_ipages(path, page):
|
||||||
ppath=page.path
|
ppath=page.path
|
||||||
ps=[p for p in flatpages if p.path.startswith(path) and not ( re.match('.*index',p.path) is None) and ( re.match(ppath,p.path) is None)]
|
cc=len(path.split('/'))
|
||||||
|
if path=="":
|
||||||
|
cc=0
|
||||||
|
ps=[p for p in flatpages if p.path.startswith(path) and not ( re.match('.*index',p.path) is None) and ( re.match(ppath,p.path) is None) and len(p.path.split('/'))<=cc+2 ]
|
||||||
return ps
|
return ps
|
||||||
|
|
||||||
def get_flatpage(path):
|
def get_flatpage(path):
|
||||||
is_index=False
|
is_index=False
|
||||||
|
if path == 'index' or path=='':
|
||||||
|
is_index=True
|
||||||
|
path=''
|
||||||
|
pathi='index'
|
||||||
|
else:
|
||||||
if path.split('/')[-1]=='index':
|
if path.split('/')[-1]=='index':
|
||||||
is_index=True
|
is_index=True
|
||||||
path='/'.join(path.split('/')[0:-1])
|
path='/'.join(path.split('/')[0:-1])
|
||||||
|
|||||||
Reference in New Issue
Block a user