Giter Site home page Giter Site logo

Comments (13)

jhvst avatar jhvst commented on May 23, 2024

Currently I'm not aware of way to add this, expect for writing a middleware and modifying every render call in routes...

Look forward to #27, it will most likely added in there.

from vertigo.

jayrox avatar jayrox commented on May 23, 2024

you can fix this easily.

in the template add something like:

{{ if loggedin .Session }}
    <a href="/user">User</a>
    <a href="/user/logout">Log out</a>
{{ else }}
    <a href="/user/login">Log in</a>
    {{ if allowregistrations . }}<a href="/user/register">Register</a>{{ end }}
{{ end }}

and in main.go add a "loggedin" template helper:

"loggedin": func(session sessions.Session) bool {
    return sessionIsAlive(session)
},

will also need a struct to hold and pass the session to rendered output.

i created a file called "page.go" to store the following code:

package main

import "github.com/martini-contrib/sessions"

type Page struct {
    Session sessions.Session
    Data    interface{}
    Err     string
}

then to use it you'll need to modify the function that renders, like this:
for example the posts.go homepage method:

// Homepage route fetches all posts from database and renders them according to "home.tmpl".
// Normally you'd use this function as your "/" route.
func Homepage(res render.Render, db *gorm.DB, s sessions.Session) {
    if Settings.Firstrun {
        res.HTML(200, "installation/wizard", nil)
        return
    }
    var post Post
    posts, err := post.GetAll(db)
    if err != nil {
        log.Println(err)
        res.JSON(500, map[string]interface{}{"error": "Internal server error"})
        return
    }

    res.HTML(200, "home", Page{Session: s, Data: posts})
}

another modification requires using the .Data variable:
in post/display.tmpl:

<article>
    <small><time>{{date .Data.Created}}</time></small>
    <h1>{{.Data.Title}}</h1>
    {{unescape .Data.Content}}
</article>

from vertigo.

jayrox avatar jayrox commented on May 23, 2024

i know that actually ends up being a ton of updates and changes but it adds a ton of power.

from vertigo.

jhvst avatar jhvst commented on May 23, 2024

Thanks @jayrox. The method you described is the same to what I've resorted to use in other apps. Though, I hope this could achieved in some easier way.

I'm going to replace martini with negroni or gin soon, which might give new ways to resolve this problem. In general, the barebones HTTP middleware used by negroni and gin should be a lot more versatile. I'll try to find the time to check up on this during the next week, during which I'll also be merging the database-as-drivers branch. After that getting rid of martini should be pretty straightforward.

Also, @jayrox, any comments on the database-as-drivers branch are welcome. Should you find anything which bothers your mind, let me know about it on #25. I'll probably end up creating an organization for the database plugins, which will then be imported as git submodules on this repository.

from vertigo.

jayrox avatar jayrox commented on May 23, 2024

i've been working on replacing martini and have it basically working except the tests.

from vertigo.

jhvst avatar jhvst commented on May 23, 2024

@jayrox I added you as a collaborator. I will soon merge the database-drivers branch to the master. I would then like you to fork it and apply the changes regarding martini into a new branch. I could check up on any issues you might have with the tests. The tests itself do not have anything martini specific, so if the server works as a normal HTTP server, everything should be about fine.

I will reference the commits to this issue once I push any code.

from vertigo.

 avatar commented on May 23, 2024

@9uuso I didn't want to start another issue for this, but shouldn't vertigo have a way in which themes can simply be implemented such as Ghost or Wordpress? This is possibly around the same bout, shouldn't we add a default theme for the blog and then a separate for the admin type section.

from vertigo.

jayrox avatar jayrox commented on May 23, 2024

ideally with these little helpers themes will be very doable.

if you look at my fork (the version i use to host my personal copy) you can see some of the helpers i've added.

my version uses polymer which pretty much shows you can do anything you want theme wise. if there is any interest we can certainly look into merging some, any or all of these changes to this repo.

from vertigo.

 avatar commented on May 23, 2024

@jayrox your example code above is initially the thing that should be implemented before anything else, is it already committed onto your forked source?

from vertigo.

jayrox avatar jayrox commented on May 23, 2024

Yes
On May 19, 2015 9:35 PM, "My-khael Pierce" [email protected] wrote:

@jayrox https://github.com/jayrox your example code above is initially
the thing that should be implemented before anything else, is it already
committed onto your forked source?


Reply to this email directly or view it on GitHub
#32 (comment).

from vertigo.

jhvst avatar jhvst commented on May 23, 2024

I didn't want to start another issue for this, but shouldn't vertigo have a way in which themes can simply be implemented such as Ghost or Wordpress?

Yes, this is a feature I've thought about earlier.

That being said, journey did integrate Ghost themes into their engine (which is interesting and appealing feature) which Vertigo could benefit as well. However, I'm afraid it would introduce too much restrictions on what you can and what you can't do with templates. In addition, the way the Ghost templates are parsed looks rather complicated to me.

If the functionality would be imported as a nice package, which would work nicely with html/template, then it might be a different thing.

This is possibly around the same bout, shouldn't we add a default theme for the blog and then a separate for the admin type section.

The blog and admin section do not need separate themes.

However, themes should be able to override default templates, provide helper functions in Go and override or provide their own CSS and JS. Doing this will require some modifications at least to the settings, so its not all too straightforward. Although, implementing this feature now would not be a gigantic effort either, so I'll have a look at it as soon as I find the time and willingness.

@jayrox I'll check out your repo and I find any code to merge, I'll setup a new branch.

from vertigo.

jhvst avatar jhvst commented on May 23, 2024

This will be "fixed" with a single User CP link which leads to login page (/user) if you are logged in. If you are not logged in, you should see a register link where you can register.

I've been also working on new frontend design, which looks like this a the moment:

screenshot 2015-10-04 02 10 39

The social media links will be removed from the base theme, since managing the links would need HTML editing. Page name and description (in this case Juuso Haavisto and Blog of a computer whisperer) will be fetched from settings, so they can be changed without knowledge of HTML.

I'll push the changes once I get compatibility problems with schemas resolved. Currently gorm has been removed from the codebase, and sqlx has been added. SQLite works currently, but MySQL and PostgreSQL have some issues.

from vertigo.

jhvst avatar jhvst commented on May 23, 2024

I decided to keep the RSS logo in the base theme.

PostgreSQL integration is only one bug away.

from vertigo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.