mirror of
https://codeberg.org/etux/Node_App_Template.git
synced 2025-12-22 05:07:09 +00:00
67 lines
1.5 KiB
Plaintext
Executable File
67 lines
1.5 KiB
Plaintext
Executable File
#!/usr/bin/env python3
|
|
|
|
# Import required modules
|
|
import core
|
|
import os
|
|
|
|
# Must be browsing locally, create fake link_id
|
|
if 'link_id' not in os.environ:
|
|
os.environ['link_id'] = 'local_test'
|
|
|
|
# Check if current link_id is loged in as a user.
|
|
current_session = core.get_current_session(os.environ['link_id'])
|
|
|
|
# Display the header, i.e. title, menu, etc.
|
|
core.header(current_session)
|
|
|
|
# Display same thing, regardless of user logged in or not.
|
|
print('''This page demonstrates how to add content, and define who can see it.
|
|
''')
|
|
|
|
# If user is logged in
|
|
if current_session:
|
|
print('''User logged in.
|
|
Display content to logged in users here.
|
|
|
|
Examples of other "plugins" for logged in users:
|
|
`!`[Micro Blog`:/page/user_blog.mu]`!
|
|
|
|
''')
|
|
|
|
# OPTIONAL:
|
|
# Only display if user has a role. A role can be anything. It is a text string.
|
|
if current_session['role'] == 'admin':
|
|
print('You have the role admin.')
|
|
|
|
if current_session['role'] == 'moderator':
|
|
print('You have the role moderator.')
|
|
|
|
if current_session['role'] == 'user':
|
|
print('You have the role user.')
|
|
|
|
|
|
# If user is logged out
|
|
if not current_session:
|
|
print('''
|
|
User not logged in.
|
|
''')
|
|
|
|
# Display same thing, regardless of user logged in or not.
|
|
print('''Everyone can see this.
|
|
|
|
"Plugins" that anyone can view:
|
|
|
|
`!`[Bulletin Board`:/page/bulletin_board.mu]`!
|
|
`!`[Stats`:/page/stats.mu]`!
|
|
`!`[Wiki`:/page/wiki.mu]`!
|
|
`!`[Market Listings`:/page/market.mu]`!
|
|
`!`[File Browser`:/page/files.mu]`!
|
|
|
|
|
|
|
|
|
|
''')
|
|
|
|
# Display footer text
|
|
core.footer()
|