私のウェブサイトでは、Python(.py)ファイルなど、ダウンロードするコードファイルはほとんどありません。ダウンロード用の<a>
タグがありますが、ダウンロードする前にソースコードを表示したいと考えています。マウスを動かすとiframeを表示できますが、コードを表示するのに問題があります。iframeのソースコードですか?
FYI:すべてのgithubページを使用していますが、ファイルはサイトリポジトリにあります。
DLリストのジーコード。
<ul class="dl-display">
<!-- get the folder name that the index..html file is contained in -->
{% assign path_array = page.path | split: '/' %}
{% assign path_array_rev = path_array | reverse %}
{% assign page_dir = path_array_rev[1] | prepend: '/'%}
{% for item in site.static_files %}
{% if item.path contains page_dir %}
{% unless item.path contains 'index.html' %}
{% assign split_path = item.path | split: '/' %}
{% assign filename = split_path.last %}
{% assign rev_split_path = split_path | reverse %}
{% assign dirname = rev_split_path[1] %}
{% unless item.path contains '.txt' %}
<li><a href="{{site.baseurl}}{{item.path}}" download>{{filename}} <iframe id="sourcetooltip" src='{{item.path}}'></iframe></a></li>
{% endunless %}
{% if item.path contains 'description.txt' %}
<iframe src='{{item.path}}' scrolling='no' frameborder='0'></iframe>
{% endif %}
{% endunless %}
{% endif %}
{% endfor %}
</ul>
申し訳ありませんがコードがちょっと混乱していても、私はまだウェブ開発にはかなり新しいです。
filenameがdescription
のときにiframeを表示するコードは完全に動作し、テキストが表示されます。
このブロックでは、ファイルがダウンロードされます。 txtファイルをダウンロードする代わりに表示されるような.pyファイルを表示する方法はありますか?
申し訳ありませんが、私ははっきりしていない場合は、HTML、CSS、JS、およびWeb開発で使用されているもので初めてです。