mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
i2p: Minor styling changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
14b581c96d
commit
ba4d73ae60
11
actions/i2p
11
actions/i2p
@ -15,7 +15,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Wrapper to list and handle system services
|
Wrapper to list and handle system services
|
||||||
"""
|
"""
|
||||||
@ -28,7 +27,7 @@ from plinth import action_utils, cfg
|
|||||||
cfg.read()
|
cfg.read()
|
||||||
module_config_path = os.path.join(cfg.config_dir, 'modules-enabled')
|
module_config_path = os.path.join(cfg.config_dir, 'modules-enabled')
|
||||||
|
|
||||||
I2P_CONF_DIR = "/var/lib/i2p/i2p-config"
|
I2P_CONF_DIR = '/var/lib/i2p/i2p-config'
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
@ -89,7 +88,7 @@ def subcommand_add_favorite(arguments):
|
|||||||
:param arguments:
|
:param arguments:
|
||||||
:type arguments:
|
:type arguments:
|
||||||
"""
|
"""
|
||||||
router_config_path = os.path.join(I2P_CONF_DIR, "router.config")
|
router_config_path = os.path.join(I2P_CONF_DIR, 'router.config')
|
||||||
# Read config
|
# Read config
|
||||||
with open(router_config_path) as config_file:
|
with open(router_config_path) as config_file:
|
||||||
config_lines = config_file.readlines()
|
config_lines = config_file.readlines()
|
||||||
@ -101,10 +100,10 @@ def subcommand_add_favorite(arguments):
|
|||||||
line = config_lines[i]
|
line = config_lines[i]
|
||||||
|
|
||||||
# Find favorites line
|
# Find favorites line
|
||||||
if line.startswith("routerconsole.favorites"):
|
if line.startswith('routerconsole.favorites'):
|
||||||
found_favorites = True
|
found_favorites = True
|
||||||
if url in line:
|
if url in line:
|
||||||
print("URL already in favorites")
|
print('URL already in favorites')
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Append favorite
|
# Append favorite
|
||||||
@ -130,7 +129,7 @@ def subcommand_add_favorite(arguments):
|
|||||||
with open(router_config_path, mode='w') as config_file:
|
with open(router_config_path, mode='w') as config_file:
|
||||||
config_file.writelines(config_lines)
|
config_file.writelines(config_lines)
|
||||||
|
|
||||||
print("Added '%s' to favorites" % url)
|
print('Added {} to favorites'.format(url))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@ -24,6 +24,7 @@ from plinth import action_utils, actions, frontpage
|
|||||||
from plinth import service as service_module
|
from plinth import service as service_module
|
||||||
from plinth.menu import main_menu
|
from plinth.menu import main_menu
|
||||||
from plinth.modules.users import register_group
|
from plinth.modules.users import register_group
|
||||||
|
|
||||||
from .manifest import backup, clients
|
from .manifest import backup, clients
|
||||||
|
|
||||||
version = 1
|
version = 1
|
||||||
@ -58,18 +59,17 @@ service = None
|
|||||||
manual_page = 'I2P'
|
manual_page = 'I2P'
|
||||||
|
|
||||||
additional_favorites = [
|
additional_favorites = [
|
||||||
("Searx instance", "http://ransack.i2p"),
|
('Searx instance', 'http://ransack.i2p'),
|
||||||
("Torrent tracker", "http://tracker2.postman.i2p"),
|
('Torrent tracker', 'http://tracker2.postman.i2p'),
|
||||||
("YaCy Legwork", "http://legwork.i2p"),
|
('YaCy Legwork', 'http://legwork.i2p'),
|
||||||
("YaCy Seeker", "http://seeker.i2p"),
|
('YaCy Seeker', 'http://seeker.i2p'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Intialize the module."""
|
"""Intialize the module."""
|
||||||
menu = main_menu.get('apps')
|
menu = main_menu.get('apps')
|
||||||
menu.add_urlname(name, 'i2p', 'i2p:index',
|
menu.add_urlname(name, 'i2p', 'i2p:index', short_description)
|
||||||
short_description)
|
|
||||||
register_group(group)
|
register_group(group)
|
||||||
|
|
||||||
global service
|
global service
|
||||||
@ -87,7 +87,6 @@ def init():
|
|||||||
|
|
||||||
def setup(helper, old_version=None):
|
def setup(helper, old_version=None):
|
||||||
"""Install and configure the module."""
|
"""Install and configure the module."""
|
||||||
|
|
||||||
helper.install(managed_packages)
|
helper.install(managed_packages)
|
||||||
|
|
||||||
# Add favorites to the configuration
|
# Add favorites to the configuration
|
||||||
@ -105,21 +104,21 @@ def setup(helper, old_version=None):
|
|||||||
], is_external=True, is_enabled=is_enabled, enable=enable,
|
], is_external=True, is_enabled=is_enabled, enable=enable,
|
||||||
disable=disable,
|
disable=disable,
|
||||||
is_running=is_running)
|
is_running=is_running)
|
||||||
|
|
||||||
helper.call('post', service.notify_enabled, None, True)
|
helper.call('post', service.notify_enabled, None, True)
|
||||||
helper.call('post', add_shortcut)
|
helper.call('post', add_shortcut)
|
||||||
|
|
||||||
|
|
||||||
def add_shortcut():
|
def add_shortcut():
|
||||||
"""Helper method to add a shortcut to the frontpage."""
|
"""Helper method to add a shortcut to the frontpage."""
|
||||||
frontpage.add_shortcut('i2p', name,
|
frontpage.add_shortcut('i2p', name, short_description=short_description,
|
||||||
short_description=short_description,
|
|
||||||
url='/i2p/', login_required=True,
|
url='/i2p/', login_required=True,
|
||||||
allowed_groups=[group[0]])
|
allowed_groups=[group[0]])
|
||||||
|
|
||||||
|
|
||||||
def is_running():
|
def is_running():
|
||||||
"""Return whether the service is running."""
|
"""Return whether the service is running."""
|
||||||
return action_utils.service_is_running("i2p")
|
return action_utils.service_is_running('i2p')
|
||||||
|
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
@ -129,13 +128,13 @@ def is_enabled():
|
|||||||
|
|
||||||
def enable():
|
def enable():
|
||||||
"""Enable the module."""
|
"""Enable the module."""
|
||||||
actions.superuser_run("i2p", ["enable"])
|
actions.superuser_run('i2p', ['enable'])
|
||||||
add_shortcut()
|
add_shortcut()
|
||||||
|
|
||||||
|
|
||||||
def disable():
|
def disable():
|
||||||
"""Enable the module."""
|
"""Enable the module."""
|
||||||
actions.superuser_run("i2p", ["disable"])
|
actions.superuser_run('i2p', ['disable'])
|
||||||
frontpage.remove_shortcut('i2p')
|
frontpage.remove_shortcut('i2p')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user