【问题标题】:Customize welcome page of ipython notebook自定义 ipython notebook 的欢迎页面
【发布时间】:2014-11-27 19:09:54
【问题描述】:

我可以自定义 iPython 笔记本服务器(2.3 版)的登录页面吗?

我的意思是,在起始页面(类似于:http://localhost:8888/tree),我想显示 Welcome to the i[Py] Notebook of John Doe 或修改现有横幅。 . 这可能吗?

【问题讨论】:

    标签: html css ipython ipython-notebook


    【解决方案1】:

    您可以使用 custom.css 更改横幅徽标或将其替换为文本。

    自定义标题

    要简单地更改文本,请添加以下行

    #ipython_notebook::before{content:"Welcome to my notebook"}
    #ipython_notebook img{display:none;}
    

    当然可能需要一些额外的样式。

    自定义横幅徽标

    要更改横幅徽标,请准备一个徽标并确保其安全,例如在 ~/.ipython/profile_default/static/custom/logo.png 中。将以下内容添加到您的 custom.css

    #ipython_notebook img{
    display:block;
    background: url(/static/custom/logo.png) no-repeat;
    width: 233px;
    height: 33px;
    padding-left: 233px;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    }
    

    使用后者(以及一些额外的 CSS 着色),我的仪表板看起来像 :)

    我从 this 最近的邮件列表中获得了大部分信息,并从 here 获得了必要的 CSS。 This 一组“黑客”笔记本可能也很有趣。

    【讨论】:

    • 谢谢你,@Jakob !!你是如何隐藏文本“i[Py]Notebook”的?
    • 我是这样做的..#ipython_notebook a img[src*="ipynblogo"] { display: none; }你有更好的解决方案吗?
    • 在第二个解决方案中 IP[y]:Notebook 即。横幅图像移到可见图像框架之外(请参阅我发布的链接)。只是隐藏banner图片是#ipython_notebook img{display:none;}实现的(其实和你评论的一样)。
    【解决方案2】:

    这是我采用的custom.css,以防有人对更广泛的定制感兴趣:

    body { background-color: #fcfcfc !important; }
    
    body, p, div.rendered_html { 
        color: #336699;
        font-family: Optima,Segoe,Segoe UI,Candara,Calibri,Arial,sans-serif;
        font-size: 11pt;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #003366;
    }
    
    #notebook { 
        background-color: #ffffff !important;
    }
    
    /* header - notebook */
    
    #ipython_notebook a img[src*="ipynblogo"] {
        display: none;
    }
    
    #ipython_notebook a{
        display:block;
        background: url(banner.png) no-repeat;
        width: 250px;
        height: 70px;
        padding-left: 10px;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }
    
    span#notebook_name {
        color: #993333;
        height: 1em;
        line-height: 1em;
        padding: 2px;
        border: medium none;
        font-size: 90.0%;
        font-variant: small-caps;
    }
    #menubar-container {
        font-size: 9pt;
    }
    
    #menubar .navbar-inner {
        min-height: 12px;
        border-top: 1px none;
        border-radius: 0px 0px 2px 2px;
        border: 2px solid #cccccc;
    }
    
    .navbar-default, .navbar-static-top {
        background-color: #ffffff !important;
        color: #999999 !important;
    }
    
    #maintoolbar { padding-top: 0.1em; padding-bottom: 0.1em; }
    
    
    /* Forms and menus */
    
    .dropdown-menu { background-color: #ffffff !important; border: none !important; }
    .dropdown-menu > li > a { color: #003366 !important; }
    .dropdown-menu > li > a:hover { color: #ffffff !important; }
    .dropdown-menu > li.disabled > a { color: #cccccc !important; }
    
    /* Cell styling */
    div.cell {
        border-radius: 0px 0px 2px 2px;
        border: 1px solid #fcfcfc !important;
    }
    div.cell.selected {
        border-radius: 0px 0px 2px 2px;
        border-color: #f0f000 !important;
    }
    div.cell.edit_mode { border-color: #f00000 !important; }
    div.input_prompt { color: #ff6600 !important; }
    div.output_prompt { color: #ff0066 !important; }
    
    div.input_area { 
        background: #fefefe !important;
        border: 1px solid #d1d1d1 !important;   
    }
    
    .celltoolbar {
        background: #eee8d5 !important;
        color: #586e75 !important;
        border: 1px solid #002b36 !important;
    }
    
    /* CodeMirror Styling */
    
    .cm-s-ipython {
        font-family: Andale Mono,AndaleMono,monospace;
        font-size: 12px;
        line-height: 1.15em;
        color-profile: sRGB;
        rendering-intent: auto;
        background-color: #fbfdff;
        color: #93a1a1;
        text-shadow: none;
        border-radius: 4px;
    }
    
    /* Cursor */
    
    .cm-s-ipython div.CodeMirror-cursor {
        border: none;
        width: 0.6em;
        background-color: rgba(5, 105, 205, 0.1);
    }
    
    /* Gutters */
    
    .cm-s-ipython .CodeMirror-gutters {
      border-right: 1px solid;
    }
    
    .cm-s-ipython .CodeMirror-gutters {
      background-color:  #002b36;
      border-color: #00232c;
    }
    
    .cm-s-ipython .CodeMirror-linenumber {
      text-shadow: #021014 0 -1px;
      padding: 0 8px 0 0;
      color: #586e75;
    }
    
    .cm-s-ipython .CodeMirror-guttermarker-subtle { color: #586e75; }
    .cm-s-ipython .CodeMirror-guttermarker { color: #ddd; }
    
    /* Syntax highlighting */
    
    .cm-s-ipython span.cm-keyword { color: #00994c }
    .cm-s-ipython span.cm-atom { color: #d33682; }
    .cm-s-ipython span.cm-number { color: #0080FF; }
    .cm-s-ipython span.cm-def { color: #268bd2; font-weight: bold; }
    
    .cm-s-ipython span.cm-variable { color: #111111; }
    .cm-s-ipython span.cm-variable-2 { color: #b58900; }
    .cm-s-ipython span.cm-variable-3 { color: #6c71c4; }
    
    .cm-s-ipython span.cm-property { color: #2aa198; }
    .cm-s-ipython span.cm-operator {color: #d33682; }
    
    .cm-s-ipython span.cm-comment { color: #aaaaaa; font-style: italic; }
    
    .cm-s-ipython span.cm-string { color: #cc6600; }
    .cm-s-ipython span.cm-string-2 { color: #aa91dd; }
    
    .cm-s-ipython span.cm-meta { color: #859900; }
    .cm-s-ipython span.cm-qualifier { color: #b58900; }
    .cm-s-ipython span.cm-builtin { color: #859900; }
    .cm-s-ipython span.cm-bracket { color: #cb4b16; }
    .cm-s-ipython .CodeMirror-matchingbracket { color: #b58900 !important; font-weight: bold; }
    .cm-s-ipython .CodeMirror-nonmatchingbracket { color: #dc322f; }
    .cm-s-ipython span.cm-tag { color: #93a1a1 }
    .cm-s-ipython span.cm-attribute {  color: #2aa198; }
    .cm-s-ipython span.cm-header { color: #586e75; }
    .cm-s-ipython span.cm-quote { color: #93a1a1; }
    .cm-s-ipython span.cm-hr {
      color: transparent;
      border-top: 1px solid #586e75;
      display: block;
    }
    .cm-s-ipython span.cm-link { color: #93a1a1; cursor: pointer; }
    .cm-s-ipython span.cm-special { color: #6c71c4; }
    .cm-s-ipython span.cm-em {
      color: #999;
      text-decoration: underline;
      text-decoration-style: dotted;
    }
    .cm-s-ipython span.cm-strong { color: #eee; }
    
    .cm-s-ipython span.cm-tab:before {
      content: "➤";
      color: #586e75;
      position:absolute;
    }
    .cm-s-ipython span.cm-error,
    .cm-s-ipython span.cm-invalidchar {
      color: #586e75;
      border-bottom: 1px dotted #dc322f;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-04
      • 2015-03-28
      • 1970-01-01
      • 2011-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多