浏览代码

加入 about 页面

James Iter 7 年之前
父节点
当前提交
2ec52d5f32

+ 1 - 0
docs/todo.md

@@ -97,5 +97,6 @@
 - [ ] 在 About 页面,加入更新功能
 - [ ] 大于 内存、负载 百分比后,禁止创建虚拟机
 - [x] 考虑用 /etc/machine-id 替换 node_id
+- [ ] 邮局设置从配置文件提取到JimV系统配置中
 
 

+ 3 - 1
jimvc/__init__.py

@@ -31,8 +31,8 @@ from jimvc.models import EventProcessor
 from jimvc.models import Database as db
 from jimvc.models import Config
 from jimvc.models import User
-from jimvc.api.user import blueprint as user_blueprint
 
+from jimvc.api.user import blueprint as user_blueprint
 from jimvc.api.os_template_image import blueprint as os_template_image_blueprint
 from jimvc.api.os_template_image import blueprints as os_template_image_blueprints
 from jimvc.api.os_template_initialize_operate_set import blueprint as os_template_initialize_operate_set_blueprint
@@ -60,6 +60,7 @@ from jimvc.api.host_performance import blueprint as host_performance_blueprint
 from jimvc.api.host_performance import blueprints as host_performance_blueprints
 from jimvc.api.dashboard import blueprint as dashboard_blueprint
 from jimvc.api.dashboard import blueprints as dashboard_blueprints
+from jimvc.api.about import blueprint as about_blueprint
 
 from jimvc.views.error_pages import *
 from jimvc.views.config import blueprint as view_config_blueprint
@@ -263,6 +264,7 @@ try:
     app.register_blueprint(host_performance_blueprints)
     app.register_blueprint(dashboard_blueprint)
     app.register_blueprint(dashboard_blueprints)
+    app.register_blueprint(about_blueprint)
 
     app.register_blueprint(view_config_blueprint)
     app.register_blueprint(view_misc_blueprint)

+ 43 - 0
jimvc/api/about.py

@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+import jimit as ji
+from flask import Blueprint
+
+from jimvc.models import Utils
+
+
+__author__ = 'James Iter'
+__date__ = '2018/10/2'
+__contact__ = 'james.iter.cn@gmail.com'
+__copyright__ = '(c) 2018 by James Iter.'
+
+
+blueprint = Blueprint(
+    'api_about',
+    __name__,
+    url_prefix='/api/about'
+)
+
+blueprints = Blueprint(
+    'api_abouts',
+    __name__,
+    url_prefix='/api/abouts'
+)
+
+
+@Utils.dumps2response
+def r_get():
+    ret = dict()
+    ret['state'] = ji.Common.exchange_state(20000)
+    ret['data'] = {
+        'version': 0.7,
+        'desc': """
+    JimV 是一套舒适的驾驭系统。通过它,您可以可以轻松自如地,让那匹彪悍烈马,把您带上长空云霄。
+    "舒适",是设计 JimV 的哲学理念。其中包含的意义有 "平滑、自在、敏捷、可控"。您所想、所要的,
+只需轻触鼠标,即可信手捏来。""",
+        'copyright': '版权所有2018 JamesIter. 保留所有权利。'
+    }
+
+    return ret

+ 3 - 2
jimvc/api_route_table.py

@@ -5,8 +5,7 @@
 from jimvc.models import add_rule_api
 from jimvc.api import config, os_template_profile, snapshot, os_template_initialize_operate, user, ssh_key, \
     os_template_image, guest_performance, disk, log, os_template_initialize_operate_set, dashboard, guest, host, \
-    host_performance
-
+    host_performance, about
 
 __author__ = 'James Iter'
 __date__ = '2017/03/30'
@@ -16,6 +15,8 @@ __copyright__ = '(c) 2017 by James Iter.'
 
 # JimV 配置操作
 add_rule_api(config.blueprint, '', api_func='config.r_create', methods=['POST'])
+# JimV 关于操作
+add_rule_api(about.blueprint, '', api_func='about.r_get', methods=['GET'])
 # 只有一条记录,所以不指定 id
 add_rule_api(config.blueprint, '', api_func='config.r_update', methods=['PATCH'])
 add_rule_api(config.blueprint, '/_quota', api_func='config.r_update_quota', methods=['PATCH'])

+ 54 - 0
jimvc/themes/default/templates/about.html

@@ -0,0 +1,54 @@
+{% extends theme("layout.html") %}
+{% block head %}
+    {{ super() }}
+
+    <style type="text/css">
+
+        label>span {
+            color: deepskyblue;
+        }
+
+        .btn,
+        .form-group>div>div,
+        .form-control {
+            border-radius: 0;
+        }
+    </style>
+{% endblock head %}
+{% block content %}
+    <script>
+        $(document).ready(function() {
+            $.ajax({
+                url: '/api/about',
+                type : 'GET',
+                dataType: "json",
+                error : function(data, textStatus, xhr) {
+                },
+                success : function(data, textStatus, xhr) {
+                    $('#desc').text(data['data']['desc']);
+                    $('#version').text(data['data']['version']);
+                    $('#copyright').text(data['data']['copyright']);
+                }
+            });
+        });
+    </script>
+    <div class="panel">
+        <div class="panel-body" style="padding-bottom: 120px;">
+            <h3 class="title-hero" style="text-transform: unset;">
+                关于 JimV
+            </h3>
+            <div class="example-box-wrapper" style="text-align: center; top: 50px;">
+                <a href="javascript:;" class="logo-content-big" title="JimV" style="font-family: Baskerville; font-size: 120px; color: #0275d8; text-decoration: none; display: block; text-align: center;">
+                    JimV
+                </a>
+                <pre style="width: 800px; text-align: left; padding: 80px; display: inline-block;">
+                    <span id="desc"></span>
+</pre>
+                <pre style="width: 800px; display: inline-block;">
+版本 <span id="version"></span>
+<span id="copyright"></span>
+                </pre>
+            </div>
+        </div>
+    </div>
+{% endblock content %}

+ 1 - 1
jimvc/themes/default/templates/layout.html

@@ -415,7 +415,7 @@
                             </a>
                         </li>
                         <li>
-                            <a href="{{ url_for('v_config.show') }}" title="关于 JimV">
+                            <a href="{{ url_for('v_misc.about') }}" title="关于 JimV">
                                 <i class="glyph-icon icon-info"></i>
                                 <span>关于 JimV</span>
                             </a>

+ 3 - 3
jimvc/views/error_pages.py

@@ -12,9 +12,9 @@ __contact__ = 'james.iter.cn@gmail.com'
 __copyright__ = '(c) 2017 by James Iter.'
 
 
-# @app.errorhandler(404)
-# def page_not_found(error):
-#     return render('404.html'), 404
+@app.errorhandler(404)
+def page_not_found(error):
+    return render('404.html'), 404
 
 
 # @app.errorhandler(500)

+ 4 - 0
jimvc/views/misc.py

@@ -83,3 +83,7 @@ def reset_password(token):
     else:
         return render('reset_password.html', token=token)
 
+
+def about():
+    return render('about.html')
+

+ 1 - 0
jimvc/views_route_table.py

@@ -19,6 +19,7 @@ add_rule_views(misc.blueprint, 'login', views_func='misc.login', methods=['GET']
 add_rule_views(misc.blueprint, 'change_password', views_func='misc.change_password', methods=['GET'])
 add_rule_views(misc.blueprint, 'recover_password', views_func='misc.recover_password', methods=['GET', 'POST'])
 add_rule_views(misc.blueprint, 'reset_password/<token>', views_func='misc.reset_password', methods=['GET', 'POST'])
+add_rule_views(misc.blueprint, 'about', views_func='misc.about', methods=['GET'])
 
 add_rule_views(dashboard.blueprint, '', views_func='dashboard.show', methods=['GET'])