# 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.命令使用