Skip to content

Instantly share code, notes, and snippets.

@Nav4e
Created May 8, 2014 08:29
Show Gist options
  • Select an option

  • Save Nav4e/be24e8cc72ce68d96ef0 to your computer and use it in GitHub Desktop.

Select an option

Save Nav4e/be24e8cc72ce68d96ef0 to your computer and use it in GitHub Desktop.

Revisions

  1. Nav4e created this gist May 8, 2014.
    58 changes: 58 additions & 0 deletions jsbin.yasat.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    get=Ember.get

    App=Ember.Application.create()
    App.ApplicationAdapter=DS.FixtureAdapter
    App.IndexRoute=Ember.Route.extend
    model:->
    get(this,'store').find('post')



    App.IndexView=Ember.View.extend()

    str=DS.attr('string')
    num=DS.attr('number')
    App.Post=DS.Model.extend
    title:str,
    content:str,
    author:DS.belongsTo('user')

    App.User=DS.Model.extend
    userid:str,
    passwd:str,
    description:str,
    name:str,
    title:str,
    addr1:str,
    headImg:str

    App.Post.FIXTURES=[
    {
    id:1,
    title:'NAMING CONVENTIONS'
    content:'Unlike the REST Adapter, the Fixture Adapter does not make any assumptions about the naming conventions of your model. As you saw in the example above, if you declare the attribute as firstName during DS.Model.extend, you use firstName to represent the same field in your fixture data.
    Importantly, you should make sure that each record in your fixture data has a uniquely identifiable field. By default, Ember Data assumes this key is called id. Should you not provide an id field in your fixtures, or not override the primary key, the Fixture Adapter will throw an error.',
    author:1
    },
    {
    id:2,
    title:'DEFINE YOUR MODEL'
    content:"You should refer to Defining a Model for a more in-depth guide on using Ember Data Models, but for the purposes of demonstration we'll use an example modeling people who document Ember.js.",
    author:1
    }
    ]

    App.User.FIXTURES=[
    {
    id:1,
    userid:'account',
    passwd:'passwd',
    description:'simple life..',
    name:'Joson Hans',
    title:'Productor',
    addr1:'Amphitheatre Pkwy, Mountain View, CA 94043美国',
    headImg:'https://avatars0.githubusercontent.com/u/6581643?s=460'
    }
    ]


    104 changes: 104 additions & 0 deletions jsbin.yasat.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,104 @@
    <!DOCTYPE html>
    <html>
    <head>
    <script src="http://code.jquery.com/jquery.min.js"></script>
    <link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
    <meta charset="utf-8">
    <title>Ember Starter Kit</title>
    <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
    <script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
    <script src="http://builds.emberjs.com/tags/v1.5.0/ember.js"></script>
    <script src="http://builds.emberjs.com/beta/ember-data.js"></script>
    </head>
    <body>

    <script type="text/x-handlebars">
    {{partial "nav"}}
    <div class="container-full">
    <div class="row">
    <div class="col-sm-12">{{outlet}}</div>
    </div>
    </div>

    </script>

    <script type="text/x-handlebars" data-template-name="index">
    <ul>
    {{#each item in model}}
    <div class="media">
    <div class="head-image pull-left">
    <a href="#">
    <img class="media-object img-responsive" {{bindAttr alt="item.author.name"}} {{bindAttr src="item.author.headImg"}} >
    </a>
    </div>

    <div class="media-body">
    <h3 class="media-heading">{{item.title}}</h3>
    <p>{{item.content}}</p>
    </div>
    </div>
    {{/each}}
    </ul>
    </script>

    <script type="text/x-handlebars" data-template-name="_nav">
    <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">
    <li class="active"><a href="#">Link</a></li>
    <li><a href="#">Link</a></li>
    <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
    <ul class="dropdown-menu">
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
    <li><a href="#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a></li>
    <li class="divider"></li>
    <li><a href="#">One more separated link</a></li>
    </ul>
    </li>
    </ul>
    <form class="navbar-form navbar-left" role="search">
    <div class="form-group">
    <input type="text" class="form-control" placeholder="Search">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
    </form>
    <ul class="nav navbar-nav navbar-right">
    <li><a href="#">Link</a></li>
    <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
    <ul class="dropdown-menu">
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
    <li><a href="#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a></li>
    </ul>
    </li>
    </ul>
    </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
    </nav>
    </script>



    </body>
    </html>
    25 changes: 25 additions & 0 deletions jsbin.yasat.less
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    /* Put your CSS here */
    html, body {
    margin: 20px;
    }
    body {
    margin:0px;
    pardding:0px;
    padding-top: 70px;

    }

    .noradio .list-group-item {
    border-radius:0px;
    &:hover {
    background:#F3F3F3;
    }
    }

    .container-full {
    padding:0 15px;
    .head-image {
    max-width:75px;
    }
    }