requarks / wiki-v1

Legacy version (1.x) of Wiki.js
https://wiki.js.org
GNU Affero General Public License v3.0
101 stars 75 forks source link

How to show author of page #178

Open mumapu opened 5 years ago

mumapu commented 5 years ago

Hello!

How to show in footer of page the author? Any ideas?

FiyaFly commented 5 years ago

Off the top of my head, there isn't an easy or unobtrusive way to do so, but keep in mind that I don't know the code intimately. However, the quickest and simplest method I can think of is this:

At the top of your pages, where you've got the TITLE: and SUBTITLE: sections, add a section for Author:

<!-- TITLE: -->
<!-- SUBTITLE: -->
<!-- AUTHOR: -->

Then, in wiki/server/views.common/footer.pug, add this just after the ul on line 6:

    p=pageData.meta.author

Any page that you've added the Author section to will display the author Just to the left of the home button in the footer.

Hope this helps. Let me know if you come up with anything else!

FiyaFly commented 5 years ago

Just played with it a little bit to make it slightly better. This is what my footer.pug looks like:

footer.footer(class=['is-' + appconfig.theme.footer], ref='footer')
  span
    = t('footer.poweredby') + ' '
    a(href='https://github.com/Requarks/wiki') Wiki.js 1.0
    | .
  ul
    if pageData
      if pageData.meta.author
        p="Authored By: " + pageData.meta.author
    li: a(href='/')= t('footer.home')
    li: a(href='#root')= t('footer.top')

It prepends Authored By: to the name, and if there are pages that you haven't defined an author for, it doesn't put anything there, so it doesn't look kludged together.

EDIT: Was doing some minor testing (just running this stuff off the top of my head, so you're hearing it as I think of it) and the original way I had it setup, both here and above, broke the settings page. Added if pageData so it doesn't break the settings menu and such due to pageData not being defined.