Top Related Projects
HackerNews clone built with Vue 2.0, vue-router & vuex, with server-side rendering
Documentation and Samples for the Official HN API
HNPWA - Hacker News readers as Progressive Web Apps 📱
React-powered Hacker News client
"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more
Quick Overview
The weexteam/hackernews-App-powered-by-Apache-Weex repository is a Hacker News client application built using Apache Weex. It demonstrates how to create a cross-platform mobile app with Weex, showcasing its capabilities in building native-like experiences for iOS and Android using web technologies.
Pros
- Cross-platform development: Build for iOS and Android with a single codebase
- Native-like performance: Utilizes Weex's architecture for smooth, native-feeling apps
- Web technology stack: Leverages familiar web technologies (JavaScript, Vue.js) for mobile development
- Open-source example: Serves as a learning resource for developers new to Weex
Cons
- Limited community support: Apache Weex has a smaller community compared to React Native or Flutter
- Potential performance issues: Complex apps may face performance challenges compared to fully native solutions
- Learning curve: Developers need to understand Weex-specific concepts and APIs
- Dependency on third-party framework: Relies on the continued development and support of Apache Weex
Code Examples
- Rendering a list of news items:
<template>
<list class="list">
<cell v-for="item in items" :key="item.id">
<news-item :item="item"></news-item>
</cell>
</list>
</template>
<script>
import NewsItem from './NewsItem.vue'
export default {
components: { NewsItem },
data() {
return { items: [] }
},
created() {
this.fetchItems()
},
methods: {
fetchItems() {
// Fetch news items from API
}
}
}
</script>
- Navigation between screens:
const navigator = weex.requireModule('navigator')
export function push(options) {
navigator.push({
url: options.url,
animated: options.animated || 'true'
}, event => {
// Handle navigation completion
})
}
- Styling a component:
<template>
<div class="container">
<text class="title">{{ title }}</text>
</div>
</template>
<style scoped>
.container {
padding: 20px;
}
.title {
font-size: 36px;
font-weight: bold;
color: #333;
}
</style>
Getting Started
-
Install Weex Toolkit:
npm install -g weex-toolkit
-
Clone the repository:
git clone https://github.com/weexteam/hackernews-App-powered-by-Apache-Weex.git cd hackernews-App-powered-by-Apache-Weex
-
Install dependencies:
npm install
-
Run the app in development mode:
npm start
-
Build for iOS or Android:
weex platform add ios weex platform add android weex run ios weex run android
Competitor Comparisons
HackerNews clone built with Vue 2.0, vue-router & vuex, with server-side rendering
Pros of vue-hackernews-2.0
- More active development and community support
- Better documentation and examples for Vue.js developers
- Easier to integrate with existing Vue.js projects
Cons of vue-hackernews-2.0
- Limited to web platforms, unlike the cross-platform capabilities of Apache Weex
- May require additional setup for mobile-specific features
Code Comparison
vue-hackernews-2.0:
<template>
<div class="news-item">
<span class="score">{{ item.score }}</span>
<span class="title">
<a :href="item.url" target="_blank" rel="noopener">{{ item.title }}</a>
</span>
</div>
</template>
hackernews-App-powered-by-Apache-Weex:
<template>
<div class="news-item">
<text class="score">{{item.score}}</text>
<text class="title" @click="open(item.url)">{{item.title}}</text>
</div>
</template>
The main differences in the code snippets are:
- Vue-hackernews-2.0 uses standard HTML tags, while Apache Weex uses custom components like
<text>
. - Vue-hackernews-2.0 uses
:href
for linking, while Apache Weex uses a custom@click
event. - Vue-hackernews-2.0 includes additional attributes like
target="_blank"
andrel="noopener"
for better web practices.
Both implementations showcase the component-based structure of Vue.js, but Apache Weex's approach is more tailored for cross-platform development, while vue-hackernews-2.0 follows standard web development practices.
Documentation and Samples for the Official HN API
Pros of HackerNews API
- Official API provided by Hacker News, ensuring reliability and up-to-date data
- Well-documented and easy to integrate into various applications
- Supports real-time updates and efficient data retrieval
Cons of HackerNews API
- Limited to backend functionality, requires additional frontend development
- May require more setup and configuration compared to a ready-made app
- Potential rate limiting and usage restrictions
Code Comparison
HackerNews API example (JavaScript):
fetch('https://hacker-news.firebaseio.com/v0/topstories.json')
.then(response => response.json())
.then(storyIds => {
// Fetch and process individual stories
});
hackernews-App-powered-by-Apache-Weex example (Vue.js):
<template>
<list class="list">
<cell v-for="story in stories" :key="story.id">
<!-- Story item template -->
</cell>
</list>
</template>
The HackerNews API provides raw data access, allowing developers to build custom interfaces and applications. In contrast, the hackernews-App-powered-by-Apache-Weex offers a pre-built mobile application using Apache Weex, which combines web and native development.
While the API gives more flexibility for custom implementations, the Weex-powered app provides a ready-to-use solution for mobile platforms. The choice between them depends on the specific project requirements and development preferences.
HNPWA - Hacker News readers as Progressive Web Apps 📱
Pros of hacker-news-pwas
- Implements multiple Progressive Web App (PWA) versions, showcasing different frameworks and approaches
- Focuses on performance and offline capabilities, adhering to PWA best practices
- Provides a comprehensive comparison of various front-end technologies
Cons of hacker-news-pwas
- Limited to web-based implementations, lacking native mobile app capabilities
- May require more setup and configuration for each framework-specific version
- Potentially higher learning curve due to multiple technology stacks
Code Comparison
hackernews-App-powered-by-Apache-Weex:
const stream = weex.requireModule('stream')
stream.fetch({
method: 'GET',
url: 'https://hacker-news.firebaseio.com/v0/topstories.json',
type: 'json'
}, (response) => {
this.stories = response.data.slice(0, 30)
})
hacker-news-pwas (React version):
fetch('https://node-hnapi.herokuapp.com/news?page=1')
.then(response => response.json())
.then(stories => {
this.setState({ stories });
});
The hackernews-App-powered-by-Apache-Weex uses Weex-specific modules for API calls, while hacker-news-pwas utilizes standard web APIs like fetch. This highlights the difference between a native-focused approach and a web-centric implementation.
React-powered Hacker News client
Pros of react-hn
- Built with React, a popular and widely-used JavaScript library for building user interfaces
- Supports server-side rendering, improving initial load times and SEO
- Utilizes React Router for efficient client-side routing
Cons of react-hn
- Limited to web platforms, unlike the cross-platform capabilities of Apache Weex
- May have a steeper learning curve for developers not familiar with React ecosystem
- Potentially larger bundle size due to React dependencies
Code Comparison
react-hn:
const Story = ({ story, rank }) => (
<li className="Story">
<Spinner show={story === undefined}/>
{story && <StoryContent story={story} rank={rank}/>}
</li>
)
hackernews-App-powered-by-Apache-Weex:
<template>
<list class="list">
<cell v-for="(story, i) in stories" :key="i">
<story :story="story" :rank="i+1"></story>
</cell>
</list>
</template>
The code snippets show different approaches to rendering a list of stories. react-hn uses JSX syntax with React components, while the Apache Weex version uses Vue.js template syntax with custom components. The Apache Weex version appears more concise, but both achieve similar functionality in their respective frameworks.
"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more
Pros of RealWorld
- Offers a wide variety of frontend and backend implementations, providing a comprehensive learning resource for developers
- Demonstrates real-world application architecture and best practices across multiple tech stacks
- Actively maintained with a large community of contributors
Cons of RealWorld
- More complex project structure due to multiple implementations, which may be overwhelming for beginners
- Lacks focus on a specific technology or framework, potentially diluting the learning experience for those interested in a particular stack
Code Comparison
RealWorld (Angular implementation):
export class ArticleListComponent implements OnInit {
constructor(
private articlesService: ArticlesService,
private route: ActivatedRoute
) {}
ngOnInit() {
this.route.data.subscribe(
(data: { articles: Article[] }) => {
this.articles = data.articles;
}
);
}
}
HackerNews App (Weex implementation):
export default {
data: {
stories: []
},
created () {
this.fetchStories()
},
methods: {
fetchStories () {
fetch('https://hacker-news.firebaseio.com/v0/topstories.json')
.then(response => response.json())
.then(ids => {
this.stories = ids.slice(0, 10).map(id => ({ id }))
})
}
}
}
The code snippets show different approaches to data fetching and component structure, reflecting the distinct focus of each project. RealWorld demonstrates a more complex, service-based architecture, while the HackerNews App showcases a simpler, direct API interaction within the component.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Hacker News App
A mobile app for Hacker News, which is powered by Weex and Vue.
Preview
Use Weex Playground App to scan the QR code below.
The content of this QR code is
http://whatever.cn?_wx_tpl=https://raw.githubusercontent.com/weexteam/weex-hackernews/master/ios/assets/index.js
, please make sure your phone can assess GitHub.
Compile
Install the dependencies:
npm install
Compile the source code:
npm run build
# Compile the source code for web platform and native platform.npm run dev
# Watch mode fornpm run build
.
Copy the bundle file:
npm run copy:android
# Copy generated bundle file to the assets of Android project.npm run copy:ios
# Copy generated bundle file to the assets of iOS project.npm run copy
# Run bothcopy:andriod
andcopy:ios
.
More npm scripts will be find in the package.json
.
Start Web Service
npm run serve
The server is listening on 1337. Visit http://127.0.0.1:1337/index.html can preview the app on browser.
Run The Android Project
First you should install Android Studio and Android SDK.
Assuming you have configured the Android development environment properly, just use Android Studio to open the project in the android
folder, and run the app as other normal Android projects.
Run The iOS Project
First you should setup the iOS develop environment and install the CocoaPods.
Enter the ios
path, use CocoaPods to install dependencies:
pod install
Open the project in the ios
folder by Xcode, you could run the app on the simulator.
NOTE: If you want to run the app on real device, you also need to setup your own signing configuration.
Top Related Projects
HackerNews clone built with Vue 2.0, vue-router & vuex, with server-side rendering
Documentation and Samples for the Official HN API
HNPWA - Hacker News readers as Progressive Web Apps 📱
React-powered Hacker News client
"The mother of all demo apps" — Exemplary fullstack Medium.com clone powered by React, Angular, Node, Django, and many more
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot