# horizon/_conf.html
这个文件对应的路径为:\horizon\openstack_dashboard\templates\horizon\_conf.html。可以将它复制进我们的主题目录中:horizon\openstack_dashboard\themes\maintenance\templates\horizon\_conf.html。这样随便改都不会影响其它主题了。
下面我们分析下这个文件里的代码:
~~~
{% load compress %}
{% load datepicker_locale from horizon %}
{% datepicker_locale as DATEPICKER_LOCALE %}
~~~
这些不是太清楚,大概猜它是导入这些东西后,下面才能运用其对应的功能吧。
~~~
{% comment %} Compress 3rd-party (jquery, angular, etc) and top-level Horizon JS. {% endcomment %}
{% compress js %}
{% for file in HORIZON_CONFIG.xstatic_lib_files %}
<script src='{{ STATIC_URL }}{{ file }}'></script>
{% endfor %}
<script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript' charset='utf-8'></script>
{% endcompress %}
~~~
comment:相当于注释
compress js:自动压缩js代码。在这里面更改代码后,都需要在命令行中运行相关的命令,要不会报错。开发过程中,我们不应该压缩JS代码,这便于查找错误。所以我将这段代码改为以下:
~~~
{% comment %} Compress 3rd-party (jquery, angular, etc) and top-level Horizon JS. {% endcomment %}
{% for file in HORIZON_CONFIG.xstatic_lib_files %}
<script src='{{ STATIC_URL }}{{ file }}'></script>
{% endfor %}
<script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript' charset='utf-8'></script>
~~~
这样,我们在前端就能看到,它引入了那些JS代码:
~~~
<script src="/static/horizon/lib/jquery/jquery.js"></script>
<script src="/static/horizon/lib/jquery_migrate/jquery-migrate.js"></script>
<script src="/static/horizon/lib/angular/angular.js"></script>
<script src="/static/horizon/lib/angular/angular-cookies.js"></script>
<script src="/static/horizon/lib/angular/angular-sanitize.js"></script>
<script src="/static/horizon/lib/angular/angular-route.js"></script>
<script src="/static/horizon/lib/angular_bootstrap/angular-bootstrap.js"></script>
<script src="/static/horizon/lib/angular_gettext/angular-gettext.js"></script>
<script src="/static/horizon/lib/angular_lrdragndrop/lrdragndrop.js"></script>
<script src="/static/horizon/lib/angular_smart_table/smart-table.js"></script>
<script src="/static/horizon/lib/angular_fileupload/ng-file-upload-all.js"></script>
<script src="/static/horizon/lib/d3/d3.js"></script>
<script src="/static/horizon/lib/jquery_quicksearch/jquery.quicksearch.js"></script>
<script src="/static/horizon/lib/jquery_tablesorter/jquery.tablesorter.js"></script>
<script src="/static/horizon/lib/spin/spin.js"></script>
<style></style>
<script src="/static/horizon/lib/spin/spin.jquery.js"></script>
<script src="/static/horizon/lib/jquery_ui/jquery-ui.js"></script>
<script src="/static/horizon/lib/bootstrap_scss/js/bootstrap.js"></script>
<script src="/static/horizon/lib/bootstrap_datepicker/bootstrap-datepicker.js"></script>
<script src="/static/horizon/lib/hogan/hogan.js"></script>
<script src="/static/horizon/lib/rickshaw/rickshaw.js"></script>
<script src="/static/horizon/lib/jsencrypt/jsencrypt.js"></script>
<script src="/static/horizon/lib/objectpath/ObjectPath.js"></script>
<script src="/static/horizon/lib/tv4/tv4.js"></script>
<script src="/static/horizon/lib/angular_schema_form/schema-form.js"></script>
<script src="/static/horizon/js/horizon.js" type="text/javascript" charset="utf-8"></script>
~~~
这样就一目了然,开发起来也方便多了。以后我们也可以在这个文件里引入我们所需要的JS文件了。
- 1.概述
- 2.CSS样式引入
- 2.1 My Themes
- 2.2 Horizon
- 2.3 Angular
- 2.4 HORIZON_CONFIG.scss_files
- 2.5 Custom Styles
- 3. JS文件引入
- 31. iframe_embed_settings 标签
- 3.2 horizon/_conf.html
- 3.3 _script_loader.html
- 3.4 _custom_head_js.html
- 3.5 horizon/_scripts.html
- 4. 主题替换
- 4.1 ACE主题
- 4.2 引入ACE主题的CSS样式
- 4.3 引入ACE主题的JS文件
- 4.4 收集和压缩
- 4.5 总结
- 4.6 错误与冲突收集
- 5.错误修正
- 6.openstack里所有功能浏览
- 7.前端hightchart.js分析
- 8.命令使用