Giter Site home page Giter Site logo

suyash-thakur / loklak-webtweets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fossasia/loklak-webtweets

0.0 0.0 0.0 1.6 MB

FOSSASIA Tweets with loklak http://fossasia.github.io/loklak-webtweets/

Home Page: http://fossasia.github.io/loklak-webtweets/

CSS 4.25% JavaScript 0.60% HTML 0.29% Less 94.86%

loklak-webtweets's Introduction

loklak webtweets

FOSSASIA Tweets with loklak: Implement Webtweets with loklak

Objective of the mini project

Implement web tweets with loklak and substitute the implementation with twitter. Improve former implementations and reduce dependencies on additional files in repositories as much as possible. Make use of anonymous loklak API at http://api.loklak.org

Requirements

Expected Outcome

  • substitution of twitter implementation with loklak and accepted pull request
  • improvement of implementation e.g. possibility to call API with several hashtags, search term, specific accounts, time limit etc.

Links

Directions

  • To change the number of tweets being recycled, change the data-count attribute in the HTML of the div with class "tweets-feed". To change the query, change the data-query attribute to preference.
  • To require specific users and hashtags to be in the tweets, add a @ or # sign in front of the word, respectively. Separate each word by a space.
  • To require the tweet to be in a timeframe of days, add the attributes below to the "tweets-feed class":
data-start='YYYY-MM-DD' 
data-end='YYYY-MM-DD'
  • To filter out tweets from one user, add the data-from attribute.

An example of the attributes:
<div class="tweets-feed" id="tweets" data-count=50 data-query="fossasia #googlecodein" data-start="2015-12-08" data-end="2016-01-14" data-from="fossasia">

Client-side Tweets control

You can allow your viewers to control the tweets div in compliance to the controls detailed above by doing the following modifications:

Add the following to the end of index.html file, just before the closing ` tag:

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Loklak Settings</h4>
        </div>
        <div class="modal-body">
          <div class="form-group">
              <label for="query">Query:</label>
              <input class="form-control" value="fossasia #gci" id="query">
            </div>
            <div class="form-group">
              <label for="result-count">Results Count:</label>
              <input class="form-control" value="50" id="result-count">
            </div>
            <div class="form-group">
              <label for="tweet-from">Tweets From:</label>
              <input class="form-control" value="" id="tweet-from">
            </div>
            <div class="form-group">
              <label for="tweet-from-date">Tweet From Date:</label>
              <input class="form-control" value="2016-01-01" type="date" id="tweet-from-date">
            </div>
            <div class="form-group">
              <label for="tweet-to-date">Tweet To Date:</label>
              <input class="form-control" value="2016-01-18" type="date" id="tweet-to-date">
            </div>
        </div>
        <div class="modal-footer">
          <button type="button" id="submit-btn" class="btn btn-default" data-dismiss="modal">Submit</button>
        </div>
      </div>
      
    </div>
  </div>
  <script type="text/javascript">
  	$('#submit-btn').click(function(e){
  		var from = $('#tweet-from-date');
		var to = $('#tweet-to-date');
  		var date1 = new Date(from[0].value);
		var date2 = new Date(to[0].value);
		var timeDiff = Math.abs(date2.getTime() - date1.getTime());
		var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); 
		if (diffDays < 5){
			alert('Kindly provide a difference of more than 4 days between the two dates.')
		} else {
  			$('#tweets').attr('data-query', $('#query')[0].value);
  			$('#tweets').attr('data-start', $('#tweet-from-date')[0].value);
  			$('#tweets').attr('data-end', $('#tweet-to-date')[0].value);
  			$('#tweets').attr('data-from', $('#tweet-from')[0].value);
  			console.log($('#tweets').data());
  			clearInterval(interval_id);
  			$('#tweet')[0].innerHTML = 'Loading...';
  			$('#tweet-info')[0].innerHTML = 'Fetching tweets...';
  			datafetcher();
  		}
  	})
  </script>

And replace the following line:

<i class="icon social_twitter text-white"></i>

with this:

<a class="twitter-logo" data-toggle="modal" href="#myModal"><i class="icon social_twitter text-white"></i></a>

loklak-webtweets's People

Contributors

mariobehling avatar yasoob avatar dengyiping avatar jigyasa-grover avatar yagogg avatar dilpreetsio avatar divshekhar avatar codethejason avatar aryasaatvik avatar sudheesh001 avatar

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.